visual basic in excel -

D

DKehl

Hi - I would like to Copy/Paste an area dependant on how many rows there are
on a spreadsheet. I was thinking of using something like the below:

X = COUNT("D:D")

Range("A1:A" & X).Select
Selection.Copy
Range("D1:D" & X).Select
ActiveSheet.Paste
Range("E4:E" & X).Select

Setting X as the COUNT of Column D, then adding '&' X to the Range to set
the length of the Copy/Paste.
I haven't gotten it to work. Any advice?

Thanks!
 
B

Bob Phillips

X = Application.COUNT("D:D")

you might want COUNTA if there is text in the column

--

HTH

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

JE McGimpsey

What hasn't worked?

One alternative:

Range("A1:A" & Range("D" & Rows.Count).End(xlUp).Row).Copy _
Destination:=Range("D1")

Note that no selections are needed.
 
Top