How are you calling the function? I copied your function to a module. I changed it to: Function DeviceForm(rng As Range) As String If UCase(rng.Value) = "X" Then MsgBox "Row: " & rng.Row End If End Function
so that I didn't have to create a userform. then put a "X" in A2. in B2 I put: =deviceform(A2) them menu then popped up with the row # (2). I moved the X to A4, and the popup displayed (4).. is the rng.Row what you were looking for? Paul ----- Original Message ---- > From: RemyMaza <remym...@gmail.com> > To: MS EXCEL AND VBA MACROS <excel-macros@googlegroups.com> > Sent: Mon, October 11, 2010 9:49:14 AM > Subject: $$Excel-Macros$$ Custom Function with UserForm > > I have a simple function that looks at a single cell for it's value. > If it's an X, then i'd like for a form to appear. I'd like to pass > the value rng.row to the form so I can know which row I'm > manipulating. I've failed so far in my attempts to do just that. Any > tips would be awesome. > > Function DeviceForm(rng As Range) As String > If UCase(rng.Value) = "X" Then > frmDevices.Show > End If > End Function > > I'm using a custom form so the user can pick from drop-downs and I'll > update rows on a separate sheet. I'm not sure if I'm headed down the > wrong path, but here's the code for that too. I feel like I'm running > into something rookieish... Can anyone spot it? > > > Private Sub cmbAddDevice_Click() > > ActiveWorkbook.Sheets("TABLES").Range("B2").Value = cmb1.Value > > End Sub > > Private Sub cmdClear_Click() > cmb1.Value = "" > cmb2.Value = "" > cmb3.Value = "" > cmb4.Value = "" > cmb5.Value = "" > cmb6.Value = "" > cmb7.Value = "" > End Sub > > Private Sub UserForm_Initialize() > Dim arrDropDownVals As Variant > > 'Variables for drop-downs > arrDropDownVals = Array("S", "O", "G") > > With Me.cmb1 > .Clear > For i = 0 To UBound(arrDropDownVals) > .AddItem arrDropDownVals(i) > Next i > .ListIndex = 0 > End With > > With Me.cmb2 > .Clear > For i = 0 To UBound(arrDropDownVals) > .AddItem arrDropDownVals(i) > Next i > .ListIndex = 0 > End With > > With Me.cmb3 > .Clear > For i = 0 To UBound(arrDropDownVals) > .AddItem arrDropDownVals(i) > Next i > .ListIndex = 0 > End With > > With Me.cmb4 > .Clear > For i = 0 To UBound(arrDropDownVals) > .AddItem arrDropDownVals(i) > Next i > '.ListIndex = 0 > End With > > With Me.cmb5 > .Clear > For i = 0 To UBound(arrDropDownVals) > .AddItem arrDropDownVals(i) > Next i > '.ListIndex = 0 > End With > > With Me.cmb6 > .Clear > For i = 0 To UBound(arrDropDownVals) > .AddItem arrDropDownVals(i) > Next i > '.ListIndex = 0 > End With > > With Me.cmb7 > .Clear > For i = 0 To UBound(arrDropDownVals) > .AddItem arrDropDownVals(i) > Next i > '.ListIndex = 0 > End With > End Sub > > > Cheers, > Matt > > -- >---------------------------------------------------------------------------------- >- > Some important links for excel users: > 1. Follow us on TWITTER for tips tricks and links : >http://twitter.com/exceldailytip > 2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310 > 3. Excel tutorials at http://www.excel-macros.blogspot.com > 4. Learn VBA Macros at http://www.quickvba.blogspot.com > 5. Excel Tips and Tricks at http://exceldailytip.blogspot.com > > To post to this group, send email to excel-macros@googlegroups.com > > <><><><><><><><><><><><><><><><><><><><><><> > Like our page on facebook , Just follow below link > http://www.facebook.com/pages/discussexcelcom/160307843985936?v=wall&ref=ts > -- ---------------------------------------------------------------------------------- Some important links for excel users: 1. Follow us on TWITTER for tips tricks and links : http://twitter.com/exceldailytip 2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310 3. Excel tutorials at http://www.excel-macros.blogspot.com 4. Learn VBA Macros at http://www.quickvba.blogspot.com 5. Excel Tips and Tricks at http://exceldailytip.blogspot.com To post to this group, send email to excel-macros@googlegroups.com <><><><><><><><><><><><><><><><><><><><><><> Like our page on facebook , Just follow below link http://www.facebook.com/pages/discussexcelcom/160307843985936?v=wall&ref=ts