Knud
09-22-2008, 12:49 PM
Dear all Excel superusers :hi: ,
I have a challenge that I hope some of you people could help me with. The challenge is as follows:
I need to look up a value in a range. So far so good, and I have found the function "Application.vlookup(arg1, arg2, arg3, arg4)"
And this works for a specified range, but my challenge is, that my "range" is dynamic, meaning it depends on which month I'm looking at - e.g. for january the range should be "A1:B3", while the range should be "A4:B6" for february etc. My current code looks like the following:
ProjectMonthTotal = Application.VLookup(cellvalue, Sheets("Sheet1").Range(CurrentRange), 2, False)
'ProjectMonthTotal is the variable that should contain the value I'm looking for
'cellvalue is a variable containing the value I want to look up
'CurrentRange is the part that doesn't work, I don't know how to set this one up, so it will look up in the correct range each time
I'm open for all ideas, this challenge is killing me :bug:
I have a variable "Month" that always represents the month that is being calculated.
I'm using Excel 2007.
Please help me :bow:
The lost Excel ranger :rotlaugh:
I have a challenge that I hope some of you people could help me with. The challenge is as follows:
I need to look up a value in a range. So far so good, and I have found the function "Application.vlookup(arg1, arg2, arg3, arg4)"
And this works for a specified range, but my challenge is, that my "range" is dynamic, meaning it depends on which month I'm looking at - e.g. for january the range should be "A1:B3", while the range should be "A4:B6" for february etc. My current code looks like the following:
ProjectMonthTotal = Application.VLookup(cellvalue, Sheets("Sheet1").Range(CurrentRange), 2, False)
'ProjectMonthTotal is the variable that should contain the value I'm looking for
'cellvalue is a variable containing the value I want to look up
'CurrentRange is the part that doesn't work, I don't know how to set this one up, so it will look up in the correct range each time
I'm open for all ideas, this challenge is killing me :bug:
I have a variable "Month" that always represents the month that is being calculated.
I'm using Excel 2007.
Please help me :bow:
The lost Excel ranger :rotlaugh: