What am I doing wrong with this VBA range?

J

jbarrington

This works:

Dim myRange As Range

Set myRange = Worksheets("Collection").Range("H2:H4")

But the change below doesn't work for some reason and presents an error:

Dim refColumn As String
Dim myRange As Range

refColumn = "H"

Set myRange = Worksheets("Collection").Range(refColumn & "2:" &
refColumn & "4")


What have I done wrong?

Thanks in advance.
 
R

Rick Rothstein

That Set statement works fine for me (as it should) on my copy of XL2003.
Just out of curiosity, what error message are you getting? Are you sure the
Set statement is where your error is occurring at (that is, did you single
step through your code to see where the error pops up at)?
 

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