K
KR
I've renamed my worksheets in the VBE properties window ("Apple", "Pear",
"Melon"); in the Excel user view, they still show up as "sheet1", sheet2",
and "sheet3".
Now in my VBA I need to refer to a range on a selected sheet. If I hardcode
it, I can use:
Apple.Range("B4:F17").Select
but I'm pulling in the appropriate sheet name as a text string, "Apple" or
"Pear" or "Melon".
How do I use this dynamically? I'm sure it is something close to:
Dim oWrkSht as Worksheet
Set oWrkSht = "Apple"
oWrkSht.Range("B4:F17").Select
but I get a type mismatch, because the sheet can't be set to a string...
I'm sure there is an easy way to do this...
Thanks,
Keith
"Melon"); in the Excel user view, they still show up as "sheet1", sheet2",
and "sheet3".
Now in my VBA I need to refer to a range on a selected sheet. If I hardcode
it, I can use:
Apple.Range("B4:F17").Select
but I'm pulling in the appropriate sheet name as a text string, "Apple" or
"Pear" or "Melon".
How do I use this dynamically? I'm sure it is something close to:
Dim oWrkSht as Worksheet
Set oWrkSht = "Apple"
oWrkSht.Range("B4:F17").Select
but I get a type mismatch, because the sheet can't be set to a string...
I'm sure there is an easy way to do this...
Thanks,
Keith