Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 390
Default Yet Another VLOOKUP issue in VBA

Anyone know what I am doing wrong?
Here is a snip of my code:

' Calculate Yardage
Set CapRange = Worksheets("TruckInfo").Range("TruckData")
Set truck = Me.cboTruckID
Set PerFull = Me.txtPerCap

TruckCap = Application.VLookup(truck, CapRange, 8, False)

vTruckYard = TruckCap * PerFull

The "truck" variable is getting set correctly (long type)
The "PerFull" variable is getting set correctly (long type)
The code hangs-up with the Vlookup segment ("Type mismatch")

Is there a special way to pass parameters to VLOOKUP inside of VBA?

Help?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Yet Another VLOOKUP issue in VBA

TruckCap = Application.VLookup(truck.Value, CapRange, 8, False)


--

HTH

Bob Phillips

(remove nothere from the email address if mailing direct)

"Bill" wrote in message
...
Anyone know what I am doing wrong?
Here is a snip of my code:

' Calculate Yardage
Set CapRange = Worksheets("TruckInfo").Range("TruckData")
Set truck = Me.cboTruckID
Set PerFull = Me.txtPerCap

TruckCap = Application.VLookup(truck, CapRange, 8, False)

vTruckYard = TruckCap * PerFull

The "truck" variable is getting set correctly (long type)
The "PerFull" variable is getting set correctly (long type)
The code hangs-up with the Vlookup segment ("Type mismatch")

Is there a special way to pass parameters to VLOOKUP inside of VBA?

Help?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Yet Another VLOOKUP issue in VBA

When I tried it, truck was a string value, even though it was a number
in the combobox. I could get it to work if I had text values in the
lookup range first column, or if I declared truck as long. That is
likely the Type Mismatch you are seeing. Do you have Dim Truck As Long
somewhere? Are you sure it is a long?
It is usually a good idea to declare all variables, which you might be
doing, but just not showing it here.

Len


Bill wrote:
Anyone know what I am doing wrong?
Here is a snip of my code:

' Calculate Yardage
Set CapRange = Worksheets("TruckInfo").Range("TruckData")
Set truck = Me.cboTruckID
Set PerFull = Me.txtPerCap

TruckCap = Application.VLookup(truck, CapRange, 8, False)

vTruckYard = TruckCap * PerFull

The "truck" variable is getting set correctly (long type)
The "PerFull" variable is getting set correctly (long type)
The code hangs-up with the Vlookup segment ("Type mismatch")

Is there a special way to pass parameters to VLOOKUP inside of VBA?

Help?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Yet Another VLOOKUP issue in VBA

One mo

TruckCap = Application.VLookup(clng(truck.value), CapRange, 8, False)



Bill wrote:

Anyone know what I am doing wrong?
Here is a snip of my code:

' Calculate Yardage
Set CapRange = Worksheets("TruckInfo").Range("TruckData")
Set truck = Me.cboTruckID
Set PerFull = Me.txtPerCap

TruckCap = Application.VLookup(truck, CapRange, 8, False)

vTruckYard = TruckCap * PerFull

The "truck" variable is getting set correctly (long type)
The "PerFull" variable is getting set correctly (long type)
The code hangs-up with the Vlookup segment ("Type mismatch")

Is there a special way to pass parameters to VLOOKUP inside of VBA?

Help?


--

Dave Peterson
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
Vlookup issue Sri Harsha[_2_] Excel Worksheet Functions 2 February 5th 09 06:51 AM
vlookup issue MrRJ Excel Discussion (Misc queries) 9 December 12th 08 10:55 AM
Vlookup issue [email protected] Excel Discussion (Misc queries) 1 January 23rd 08 03:53 PM
VLOOKUP issue Jonah Excel Worksheet Functions 1 November 16th 05 10:54 PM
VLOOKUP issue Jonah Excel Worksheet Functions 0 November 16th 05 10:31 PM


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

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

About Us

"It's about Microsoft Excel"