View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Connie Connie is offline
external usenet poster
 
Posts: 106
Default Pass Defined Name to a Command Button

I am trying to pass a user defined name (Oracle_no) to a command
button. In the following code, I am doing a VBLOOKUP on oracle_no, but
when I debug the code, I find that oracle_no is not being passed.
Should I do this in a function instead? I guess I can't utilize
defined field names in a command button?

Private Sub Check_For_Existing_Oracle_No_Click()
Dim rng As Range
Dim Test As Variant
Sheets("Upload Data").Select
Set rng = GetRealLastCell(ActiveSheet)
lookuprange = ("$C$2:" + rng.Address)
MsgBox "oracle no follows"
MsgBox oracle_no
Test = Application.VLookup(oracle_no, Range(lookuprange), 1, False)
MsgBox IsError(Test)
MsgBox lookuprange
If IsError(Test) Then
MsgBox "It wasn't found"
Else
MsgBox "it was found"
End If
End Sub