View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
OssieMac OssieMac is offline
external usenet poster
 
Posts: 2,510
Default Vlookup - Month Instead of Day

Hi Danny,

I really don't understand what you are trying to achieve. You say that you
want to find a number in column B based on a month in Column A. In your
sample code you have rngData set to both column A and Column B so this is
confusing me.

Do you want to loop through all the data in column A and find matches to
months in column B. If so, where do you want to place the results or do you
simply want them in the MsgBox as per the code sample so that you keep
clicking OK and it finds the next one.

Perhaps you can post a sample of the data in both Column A and Column B and
then what you expect the output to be.

Regards,

OssieMac





"Danny" wrote:

Hi,

This NG provided me with the formula below to find a number on Col B based
on the date(s) on Column A.

Please edit the formula to find the number on Col B based on the "month" on
Col A.

Thank you.

Sub FindNumber()
Dim rngData As Range
Dim strPWord As String

Set rngData = Worksheets("FindNumber").Range("A:B")
strPWord = CStr(Application.VLookup(CLng(Date), rngData, 2, 0))
MsgBox strPWord

End Sub