Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am trying to write a function that loops so that I can use vlookup in
multiple ranges. The table arrays are on different sheets of the same workbook. There are twelve of them and I have named them the month name followed by 1(i.e. January1). The loop should go to the next range when it does not find the value, but currently it does not. It will only calculate for January. If someone could help that would be great. Option Explicit Function RRLookup(VRN As Variant) As Variant Dim testRng As Range Dim iCtr As Integer Dim res As Variant iCtr = 1 Set testRng = ThisWorkbook.Names(Format(DateSerial(2005, iCtr, 1), "mmmm") & "1").RefersToRange res = Application.WorksheetFunction.VLookup(VRN, testRng, 3, False) Set testRng = Nothing Do Until IsError(res) = False iCtr = iCtr + 1 Set testRng = ThisWorkbook.Names(Format(DateSerial(2005, iCtr, 1), "mmmm") & "1").RefersToRange res = Application.WorksheetFunction.VLookup(VRN, testRng, 3, False) Set testRng = Nothing If iCtr = 13 Then res = "Not Valid" End If Loop RRLookup = res End Function |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Looping | Excel Discussion (Misc queries) | |||
looping trouble | Excel Discussion (Misc queries) | |||
Looping | Excel Programming | |||
Looping | Excel Programming | |||
Looping trouble | Excel Programming |