View Single Post
  #2   Report Post  
Bob Phillips
 
Posts: n/a
Default Range used in a macro needs to be variable

Dave,

Dim rng As Range
Set rng = Range(Selection, Selection.End(xlDown)).Resize(, 6).Select

works assuming there is a selected range to start with.

If you want to use a static start point, then replace both Selection by say
Range("H1").

The 6 can be replaced by a variable with a number in it.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"DaveP" wrote in message
...
I want to highlight a range by starting in the top left hand

corner(fixed),
doing an 'end' 'down' and then right 6, because the number of rows is
variable each time, can this be down in a macro. It seems the macro

records
the actual cell references it found whilst recording the macro and

therefore
only works the first time.

I read the article under Making Excel Macros where you can use the

Variables
DIM and SET to name the range, but it relies on the user highlighting the
selection before running the macro.

I am using Excel 2000 and 2003.

Thanks