Setting range using vlookup
This is exactly the pointer I was looking for. I have made the changes
and it is working.
Thanks.
Regards,
Raj
Trooper wrote:
I am just an amateur, but I think you want to just put the worksheet name in
one cell and the range in a second sell. i.e. you can have the actual sheet
name and range as variables, and then use the Set Range =
Worksheet(variable1).Range(variable2) as a valid range. (or you can extract
the variables using string functions.)
Let's say you put "Parameters" in cell D1 on Sheet1 and ""H3:K3" in cell D2
on Sheet 1.
If you let
rpsrangvaluesheet = code for getting cell D1 on Sheet1
rpsrangevaluerange = code for getting cell D2 on Sheet1
Then your range set in Visual Basic is
Set Range = Worksheets(rpsrangevaluesheet).Range(rpsrangevalue range)
Hope this helps
"Raj" wrote:
Hi,
I want to set the range depending on a value derived by doing a
vlookup in a range.
The vlookup successfully retrieves the value and stores it in a string
variable rsprangevalue. The retrieved value stored in rsprangevalue
is:
Worksheets("Parameters").Range("H3:K3")
Next I want the range to be set using this value.
The code used for this is
Set rsprange = rsprangevalue
(rsprange is declared as a Range variable)
This fails with the "rsprangevalue" highlighted with the error message
"Type Mismatch".
Please help.
Thanks in advance for the help.
Regards,
Raj
|