Use xldown to select a range of cells

M

merry_fay

Hiya,

When I run the macro using this code:

Range("A4:R4").Select
Selection.End(xlDown).Activate
Selection.Copy

Only the bottom left cell is being selected. I need the whole range to be
selected.
Can anyone help please?

Thanks
merry_fay
 
E

Eduardo

OPPs
, I sent the message before finishing

if you want to select from A4 up to the last row used in R

Sub Macro1()
'
' Macro1 Macro
'

Dim myrange, MyRange1 As Range
lastRow = Cells(Rows.Count, "A").End(xlUp).Row
Set myrange = Sheets("Sheet1").Range("A4:R" & lastRow)
myrange.Copy
End Sub

if this helps please click yes, thanks
 
J

Jim Thomlinson

Generally speaking you are better to use xlup from the bottom (which stops at
the last complete cell of the worksheet) than xldown (which stops at the
first blank).

in either case you don't need to select

Range(Range("A4"), Cells(Rows.Count, "A").End(xlUp)).Copy
'or
Range(Range("A4"), Range("A4").End(xlDown)).Copy
 

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