PC Review


Reply
Thread Tools Rate Thread

Code seems to have not copied fully

 
 
Priyanka
Guest
Posts: n/a
 
      24th Jan 2008
Sorry-part of the code got truncated suring copy paste-here is the
full macro

Public RunWhen As Double
Public Const cRunIntervalSeconds = 900 ' two minutes
Public Const cRunWhat = "CopyDataMacro" ' the name of the procedure
to run

Dim Sht1RowCount, Sht1ColCount As Long


Public Sub Adder()
Worksheets.Add.Name() = "Sheet2"
'Calculate size of input
Sheets("Monitor").Select
Sht1RowCount = ActiveSheet.UsedRange.Rows.Count
Sht1ColCount = ActiveSheet.UsedRange.Columns.Count


Range(Cells(5, 1), Cells(5, Sht1ColCount)).Select
Range(Cells(5, 1), Cells(5, Sht1ColCount)).Copy


'Initiate Sheet2

'Copy header row from Monitor to initiate
Sheets("Sheet2").Select
Range(Cells(1, 1), Cells(1, Sht1ColCount)).Select
ActiveSheet.Paste
CopyDataMacro
End Sub

Sub StartTimer()
RunWhen = Now + TimeSerial(0, 0, cRunIntervalSeconds)
Application.OnTime EarliestTime:=RunWhen, Procedure:=cRunWhat,
Schedule:=True
End Sub
Sub CopyDataMacro()


'Select data rows from Monitor sheet
Sheets("Monitor").Select
Range(Cells(6, 1), Cells(Sht1RowCount, Sht1ColCount)).Select
Range(Cells(6, 1), Cells(Sht1RowCount, Sht1ColCount)).Copy

'Determine input in Sheet2 sheet
Sheets("Sheet2").Select
Dim LastRow, LastColumn As Long

If WorksheetFunction.CountA(Cells) > 0 Then
'Search for any entry, by searching backwards by Rows.
LastRow = Cells.Find(What:="*", After:=[A1], _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious).Row
End If

If WorksheetFunction.CountA(Cells) > 0 Then
'Search for any entry, by searching backwards by Columns.
LastColumn = Cells.Find(What:="*", After:=[A1], _
SearchOrder:=xlByColumns, _
SearchDirection:=xlPrevious).Column

End If


'Paste in Sheet2 Sheet
Range(Cells(LastRow + 1, 1), Cells(LastRow + Sht1RowCount - 1,
Sht1ColCount)).Select
Selection.PasteSpecial Paste:=xlValues
Cells(LastRow + 1, 1) = Time

'Save data
If ActiveWorkbook.Saved = False Then
ActiveWorkbook.Save
End If

' Call StartTimer to schedule the procedure
StartTimer

End Sub

Sub StopTimer()
On Error Resume Next
Application.OnTime EarliestTime:=RunWhen, Procedure:=cRunWhat,
Schedule:=False
End Sub




 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
RE: this code doesn't work fully Daniel Pineault Microsoft Access Forms 3 6th Jun 2010 02:49 PM
Re: this code doesn't work fully Douglas J. Steele Microsoft Access Forms 2 5th Jun 2010 09:16 PM
Re: this code doesn't work fully Ken Snell Microsoft Access Forms 0 4th Jun 2010 08:15 PM
Pause code until file fully downloaded Rob Oldfield Microsoft Dot NET Framework Forms 3 7th Apr 2005 10:25 PM
Execute code after form is fully loaded. David D Webb Microsoft Dot NET Compact Framework 3 16th Aug 2004 04:12 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:22 AM.