Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 87
Default How to use the worksheetfunction Vlookup

Hi----this is part of a much larger program, that I am testing
separately, if you are wondering what the heck I would use it
for. :)

I am trying to use the worksheet function vlookup in my code but it
keeps telling me

'unable to use the worksheet function vlookup class' when it gets to
that point in the code...

any idea how I should code this differently to make it work??

Thanks...


Sub makedayofweek()
Dim RANGEENTRIES As Range, NUMENTRIES As Integer, Mydate As Range,
Test As Range



Range("B22").Select

Set RANGEENTRIES = Range("B22", ActiveCell.End(xlToRight))
RANGEENTRIES.Select
NUMENTRIES = RANGEENTRIES.Columns.Count
Range("B12").Select

For i = 1 To NUMENTRIES
Set WDAY = ActiveCell
WDAY.Select
ActiveCell =
Application.WorksheetFunction.Weekday(ActiveCell.O ffset(10, 0), 2)
ActiveCell.Offset(0, 1).Select
Next i

Set Test = ActiveCell.Offset(1, 0)


Range("B11").Select
For i = 1 To NUMENTRIES
Set Mydate = ActiveCell
Mydate.Value = Application.WorksheetFunction.VLookup(Test,
Range("E53:E59"), 2)
Mydate.Offset(0, 1).Select
Next i



End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 87
Default How to use the worksheetfunction Vlookup

I figured out the problem deals with the 'Test' variable I am
using...I can't figure out how else to reference this though...
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 87
Default How to use the worksheetfunction Vlookup

I guess I didn't have to give you the whole sub...this should suffice
and make it easier on the eyes...

Test = ActiveCell.Offset(1, 0).Value

For i = 1 To NUMENTRIES
Set Mydate = ActiveCell
Mydate.Value = Application.WorksheetFunction.VLookup(Test,
Range("E53:E59"), 2)
Mydate.Offset(0, 1).Select
Next i

again, it is something wrong with the 'Test' variable in the code...
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 87
Default How to use the worksheetfunction Vlookup

I guess I didn't have to give you the whole sub...this should suffice
and make it easier on the eyes...

Test = ActiveCell.Offset(1, 0).Value

For i = 1 To NUMENTRIES
Set Mydate = ActiveCell
Mydate.Value = Application.WorksheetFunction.VLookup(Test,
Range("E53:E59"), 2)
Mydate.Offset(0, 1).Select
Next i

again, it is something wrong with the 'Test' variable in the code...
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 897
Default How to use the worksheetfunction Vlookup

Your lookup range is only one dimension, how can return the 2nd column
from a single-column range?

--JP

On Aug 13, 2:23*pm, R Tanner wrote:
I guess I didn't have to give you the whole sub...this should suffice
and make it easier on the eyes...

Test = ActiveCell.Offset(1, 0).Value

For i = 1 To NUMENTRIES
* * Set Mydate = ActiveCell
* * Mydate.Value = Application.WorksheetFunction.VLookup(Test,
Range("E53:E59"), 2)
* * Mydate.Offset(0, 1).Select
Next i

again, it is something wrong with the 'Test' variable in the code...




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 87
Default How to use the worksheetfunction Vlookup

oops...that was a typo on here. My code actually had E53:F59

what about this one? It works fine, but gives me a '#REF!' error...

cell = Range("B12").Value

ActiveCell = Application.VLookup(cell, Range("E53:E59"), 2, True)
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 897
Default How to use the worksheetfunction Vlookup

Another typo, don't you mean

ActiveCell = Application.VLookup(cell, Range("E53:F59"), 2, True)

?

My understanding is that the VBA version of vlookup returns an error
if the value isn't found. So test it with an example you KNOW should
work, then we can proceed from there.

FYI in your original example, "Test" is a Range object, you can't do
vlookup on a range object, only on values or cell references.

" Mydate.Value = Application.WorksheetFunction.VLookup(Test,
Range("E53:E59"), 2) "


HTH,
JP

On Aug 13, 3:35*pm, R Tanner wrote:
oops...that was a typo on here. *My code actually had E53:F59

what about this one? *It works fine, but gives me a '#REF!' error...

cell = Range("B12").Value

ActiveCell = Application.VLookup(cell, Range("E53:E59"), 2, True)


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
WorksheetFunction.Vlookup leerem Excel Discussion (Misc queries) 8 October 25th 08 07:58 PM
worksheetfunction.vlookup in vba pmoon7 Excel Programming 4 January 25th 06 09:00 PM
Worksheetfunction.Vlookup Robert Wilcox Excel Programming 1 May 14th 05 05:00 AM
vlookup worksheetfunction ben Excel Programming 4 February 15th 05 10:27 PM
worksheetfunction.vlookup? devnext Excel Programming 1 October 29th 03 06:41 PM


All times are GMT +1. The time now is 07:33 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"