How to reset the range name to refer to another cell?

T

Terry

I have set "G" as the a range.
In the later part, I need to use "G" as a reference to set itself as another
range.
what is the correct syntex?


Set G = Worksheets(E).Range("B21")
....
Set G = Range(G).End(xlRight) <-----Error occurs here

Please help!
 
G

Gary''s Student

You are confusing the range with its name:

Set G = Worksheets(E).Range("B21")
Set G = G.End(xlRight)
 
O

OssieMac

Hi Terry,

Also should be xlToright not just xlRight

Set g = Worksheets(E).Range("B21")

Set g = g.End(xlToRight)

I assume that E is set to a numeric value for the worksheet. If the name of
the worksheet is E then the E should be in double quotes.
--


Regards,

OssieMac
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top