Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
DKehl
 
Posts: n/a
Default visual basic in excel -

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!
  #2   Report Post  
Bob Phillips
 
Posts: n/a
Default

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)


"DKehl" wrote in message
...
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!



  #3   Report Post  
JE McGimpsey
 
Posts: n/a
Default

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.



In article ,
"DKehl" wrote:

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?

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 2003 FAILS, but Excel 2000 SUCCEEDS ??? Richard Excel Discussion (Misc queries) 2 May 13th 23 11:46 AM
I Visual Basic Error "File Not Found" when Excel opens Brent E Excel Discussion (Misc queries) 1 March 2nd 05 03:20 AM
quattro pro converter Excel 2003 dr88363 New Users to Excel 0 February 27th 05 05:00 PM
Visual Basic Code Remains in "memory" Paul Moles Excel Worksheet Functions 1 December 10th 04 10:29 PM
Excel 2003 Database Driver Visual FoxPro 7 on Server 2003. Cindy Winegarden Excel Discussion (Misc queries) 0 November 28th 04 12:07 AM


All times are GMT +1. The time now is 06:59 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"