How do I copy data from one sheet to another - the first sheet has a fixed range of data and I need to copy this to sheet2 so that data is added to the first blank row in sheet2. Also, how can I code this so that it does this periodically (every 30 seconds)?
Last edited by BigBlackMamba; 03-11-2010 at 07:48 PM.
Hi BigBlackMamba
What happens to the data on sheet1 after it's been copied to sheet2? Does it get erased? Does it stay on sheet1 and get marked as processed? If it gets marked, what column?
You indicate you want this process to run every 30 seconds. I don't know the source of the data for sheet1 and I don't know the consequences of running this procedure when sheet1 data is being updated. But, it can be done.
A sample of your data would be nice.
John
John
If you have issues with Code I've provided, I appreciate your feedback.
In the event Code provided resolves your issue, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.
If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.
Thanks for responding.
The data in Sheet 1 is will not get erased or marked as updated - it's streaming data from a data supplier. All I'm trying to do is take a snapshot of this data as fast as possible. The second sheet will be copied to a third sheet in a summarized form and then erased from sheet 2.
I don't have any sample data to show you as yet.
Are there any limitations on how fast Excel can copy this data (from sheet1 into 2)? e.g. could this be done every second or 2 seconds?
Hi BigBlackMamba
Put this code in the Workbook Module
Put this code in a general moduleCode:Option Explicit Private Sub Workbook_Open() StartTimer End Sub Private Sub Workbook_BeforeClose(Cancel As Boolean) StopTimer Call StopTimer End Sub
A sample book is attached for your perusal. The code is set to run every 2 seconds.Code:Public RunTime Option Explicit Public Sub Copy_1_To_2() Dim LR As Long LR = Sheet2.Range("A" & Rows.Count).End(xlUp).Row + 1 Sheet1.UsedRange.Copy Destination:=Sheet2.Range("A" & LR) StartTimer End Sub Sub StartTimer() RunTime = Now + #12:00:02 AM# Application.OnTime RunTime, "Copy_1_To_2", schedule:=True End Sub Sub StopTimer() On Error Resume Next Application.OnTime RunTime, "Copy_1_To_2", schedule:=False End Sub
John
John
If you have issues with Code I've provided, I appreciate your feedback.
In the event Code provided resolves your issue, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.
If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.
Thanks - that's really good!!
Hi BigBlackMamba
What you have may work well in a static world (sheet 1 is not being updated). I've no idea what happens when sheet 1 is being updated the same time the procedure runs on the timer. Guess we'll find out.
If your immediate issue is resolved, please mark your post as "solved". A click on the scales is appreciated if you feel it;s appropriate.
John
John
If you have issues with Code I've provided, I appreciate your feedback.
In the event Code provided resolves your issue, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.
If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks