#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default VBA VLOOKUP

I have a userform in my spreadsheet <frmEntry which includes a combo box
<cmb.Machine and a label <lbl.Desc.

The combo box is populated with values from column 'A' in another sheet
<Part Numbers during the userform initialization event.

I would like to code the <lbl.Desc caption by using a VLOOKUP of the
selected value in the combo box to look up the appropriate value in sheet
<Part Numbers column 'B'

The following code is giving a COMPILE ERROR, can anyone help me out here?

frmentry.lblDesc.Caption=worksheetfunction.vlookup (frmentry.cmbMachine.Value,'PartNumbers'!C1:C2,2,f alse)

DS


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 61
Default VBA VLOOKUP

I think you have set your range incorectly you are asking the function to
find column 2 in a range that only has one column,

VLookup goes
(Find this, in this range, return value from this coulumn, exact match)

Wild Guess but your range should be a1:b2






"D.S." wrote in message
...
I have a userform in my spreadsheet <frmEntry which includes a combo box
<cmb.Machine and a label <lbl.Desc.

The combo box is populated with values from column 'A' in another sheet
<Part Numbers during the userform initialization event.

I would like to code the <lbl.Desc caption by using a VLOOKUP of the
selected value in the combo box to look up the appropriate value in sheet
<Part Numbers column 'B'

The following code is giving a COMPILE ERROR, can anyone help me out here?

frmentry.lblDesc.Caption=worksheetfunction.vlookup (frmentry.cmbMachine.Value,'PartNumbers'!C1:C2,2,f alse)

DS



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default VBA VLOOKUP

DS,

VLOOKUP expects a Range or an Array as the second argument, so you use it
like

Answer = Application.Vlookup(LookupValue, Range("A1:C100"), 3, False)

or in your case (altough the range seems weird, since you only have one
column)

frmentry.lblDesc.Caption = Application.Vlookup(frmentry.cmbMachine.Value,
Range("PartNumbers!C1:C2"), 2, False)

not sure if you wanted to use C1:D2 instead...

--
Regards,

Juan Pablo González
Excel MVP

"D.S." wrote in message
...
I have a userform in my spreadsheet <frmEntry which includes a combo box
<cmb.Machine and a label <lbl.Desc.

The combo box is populated with values from column 'A' in another sheet
<Part Numbers during the userform initialization event.

I would like to code the <lbl.Desc caption by using a VLOOKUP of the
selected value in the combo box to look up the appropriate value in sheet
<Part Numbers column 'B'

The following code is giving a COMPILE ERROR, can anyone help me out here?

frmentry.lblDesc.Caption=worksheetfunction.vlookup (frmentry.cmbMachine.Value,'PartNumbers'!C1:C2,2,f alse)

DS



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default VBA VLOOKUP

Thanks,
I tried changing the code to this, but now I'm getting a "script out of
range" error.

frmEntry.lblDesc.Caption =
WorksheetFunction.VLookup(frmEntry.cmbMachine.Valu e,
Sheets("PartNumbers").Range("A2:B77"), 2, False)

D.S.

"D.S." wrote in message
...
I have a userform in my spreadsheet <frmEntry which includes a combo box
<cmb.Machine and a label <lbl.Desc.

The combo box is populated with values from column 'A' in another sheet
<Part Numbers during the userform initialization event.

I would like to code the <lbl.Desc caption by using a VLOOKUP of the
selected value in the combo box to look up the appropriate value in sheet
<Part Numbers column 'B'

The following code is giving a COMPILE ERROR, can anyone help me out here?

frmentry.lblDesc.Caption=worksheetfunction.vlookup (frmentry.cmbMachine.Value,'PartNumbers'!C1:C2,2,f alse)

DS



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,092
Default VBA VLOOKUP

Try assigning formula arguments to a variable first
Dim PartNo As String
Dim Vrange As Range

PartNo = frmEntry.cmbMachine.Value
Set Vrange = Sheets("PartNumbers").Range("A2:B77")
frmEntry.lblDesc.Caption = _
WorksheetFunction.VLookup(PartNo, _
Vrange, 2, False)

Mike F

"D.S." wrote in message
...
Thanks,
I tried changing the code to this, but now I'm getting a "script out of
range" error.

frmEntry.lblDesc.Caption =
WorksheetFunction.VLookup(frmEntry.cmbMachine.Valu e,
Sheets("PartNumbers").Range("A2:B77"), 2, False)

D.S.

"D.S." wrote in message
...
I have a userform in my spreadsheet <frmEntry which includes a combo box
<cmb.Machine and a label <lbl.Desc.

The combo box is populated with values from column 'A' in another sheet
<Part Numbers during the userform initialization event.

I would like to code the <lbl.Desc caption by using a VLOOKUP of the
selected value in the combo box to look up the appropriate value in sheet
<Part Numbers column 'B'

The following code is giving a COMPILE ERROR, can anyone help me out
here?

frmentry.lblDesc.Caption=worksheetfunction.vlookup (frmentry.cmbMachine.Value,'PartNumbers'!C1:C2,2,f alse)

DS







  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,092
Default VBA VLOOKUP

Also PartNo may need to be further qualified as:
PartNo = UserForm("frmEntry").ComboBox("cmbMachine").Value

Mike F
"Mike Fogleman" wrote in message
...
Try assigning formula arguments to a variable first
Dim PartNo As String
Dim Vrange As Range

PartNo = frmEntry.cmbMachine.Value
Set Vrange = Sheets("PartNumbers").Range("A2:B77")
frmEntry.lblDesc.Caption = _
WorksheetFunction.VLookup(PartNo, _
Vrange, 2, False)

Mike F

"D.S." wrote in message
...
Thanks,
I tried changing the code to this, but now I'm getting a "script out of
range" error.

frmEntry.lblDesc.Caption =
WorksheetFunction.VLookup(frmEntry.cmbMachine.Valu e,
Sheets("PartNumbers").Range("A2:B77"), 2, False)

D.S.

"D.S." wrote in message
...
I have a userform in my spreadsheet <frmEntry which includes a combo box
<cmb.Machine and a label <lbl.Desc.

The combo box is populated with values from column 'A' in another sheet
<Part Numbers during the userform initialization event.

I would like to code the <lbl.Desc caption by using a VLOOKUP of the
selected value in the combo box to look up the appropriate value in
sheet <Part Numbers column 'B'

The following code is giving a COMPILE ERROR, can anyone help me out
here?

frmentry.lblDesc.Caption=worksheetfunction.vlookup (frmentry.cmbMachine.Value,'PartNumbers'!C1:C2,2,f alse)

DS







Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
If (Vlookup 0) working, but what if Vlookup cell does not exist Steve Excel Worksheet Functions 18 November 18th 09 07:33 PM
VLookUp - Does the VLookUp return the exact information? Cpviv Excel Worksheet Functions 2 October 28th 08 09:57 AM
Vlookup in vlookup - taking the result as array name SupperDuck Excel Worksheet Functions 2 June 2nd 07 11:05 AM
Combine VLOOKUP and IF function so #NA isn't returned as a value from VLOOKUP buffgirl71 Excel Discussion (Misc queries) 12 November 14th 06 11:36 PM
Vlookup info being used without vlookup table attached? Excel Worksheet Functions 0 January 25th 05 10:43 AM


All times are GMT +1. The time now is 03:03 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"