Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Copy and pasting dynamically

I know I'm asking a lot of questions, so I'll try to make this my last
one hopefully.

But, how do you copy and paste dynamically?

For example, when preparing to do a pivot table, I have three
worksheets that vary in row length from day to day. I would like to
put all of the data on one sheet obviously so that I can do a pivot
table. But, the row length varies from day to day, so say I am
copying rows from worksheet A to the bottom of the data in worksheet
B. How do you tell VBA to paste it "lower" in the spreadsheet if
there are more rows or higher if there are fewer?

Thanks!

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Copy and pasting dynamically

Hi,

You can use the following code:

Sub myPT()
Dim destSht As Worksheet
Dim srcSht As Worksheet
Dim NextRow As Long

Set destSht = Sheets("Sheet B")
Set srcSht = Sheets("Sheet A")

NextRow = destSht.Cells(destSht.Rows.Count, 1).End(xlUp).Row + 1

'source sheet has a heading that I have to exclude from copy
srcSht.Cells(1).CurrentRegion.Offset(1).Copy

'I can choose to paste values
destSht.Cells(NextRow, 1).PasteSpecial xlPasteAll
End Sub

Regards
Anant

"Zarlot531" wrote in message
ps.com...
I know I'm asking a lot of questions, so I'll try to make this my last
one hopefully.

But, how do you copy and paste dynamically?

For example, when preparing to do a pivot table, I have three
worksheets that vary in row length from day to day. I would like to
put all of the data on one sheet obviously so that I can do a pivot
table. But, the row length varies from day to day, so say I am
copying rows from worksheet A to the bottom of the data in worksheet
B. How do you tell VBA to paste it "lower" in the spreadsheet if
there are more rows or higher if there are fewer?

Thanks!



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
Copy worksheets and save files dynamically BabyMc Excel Discussion (Misc queries) 3 March 19th 10 03:26 PM
Copy drop down boxes and associate to cells dynamically in excel t Killion Excel Worksheet Functions 2 June 10th 05 03:11 PM
How do I Copy data dynamically to a calculated cell Alex Smariga Excel Programming 1 June 23rd 04 04:25 PM
Dynamically pasting function from Visual Basic to Excel cell John Fejsa Excel Programming 0 February 9th 04 11:45 PM


All times are GMT +1. The time now is 05:25 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"