Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default About my looping

Just started VB for some functions that I would love to realise. but
the onlyu thing that I have for the moment is

Sub Macro2()
'
' Macro2 Macro
' Macro recorded 11/07/2007 by STD03
'

'
i = 0
Do While Now() 39269
Range("B5:G7").Select
Selection.Copy
Range("B13").Select
ActiveCell.Offset(i, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
i = i + 3
Loop
End Sub

B5:G7 is some dynamic data from other database which change
irregularly. my code makes it copy and paste in a enormous frequency.
what i want to realise is to make it copy every 5 seconds, in order to
sotck the data on a regular base.

just started VB learning and I have a very short period to make this
realised. So hope I can get some help.

Thanks a lot in advance

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default About my looping

Jonathan,

You would be better off using the OnTime method to control the data write.

Use the code below, and run StartIt to start the process, and StopIt to stop the process. This will
put the date and time into column A next to the stored values for record-keeping.

HTH,
Bernie
MS Excel MVP


Dim NextTime As Date

Sub StartIt()
Update
End Sub

Sub Update()
Dim myCell As Range
NextTime = Time + TimeValue("00:00:05")
Range("B5:G7").Copy
Set myCell = Cells(Rows.Count, 2).End(xlUp)(2)
myCell.PasteSpecial _
Paste:=xlPasteValues
With myCell.Offset(0, -1).Resize(3)
.Value = Now
.NumberFormat = "mm/dd/yy hh:mm:ss"
End With
Application.OnTime NextTime, "Update"
End Sub

Sub StopIt()
On Error Resume Next
Application.OnTime NextTime, "Update", schedule:=False
End Sub



"jonathan" wrote in message
ps.com...
Just started VB for some functions that I would love to realise. but
the onlyu thing that I have for the moment is

Sub Macro2()
'
' Macro2 Macro
' Macro recorded 11/07/2007 by STD03
'

'
i = 0
Do While Now() 39269
Range("B5:G7").Select
Selection.Copy
Range("B13").Select
ActiveCell.Offset(i, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
i = i + 3
Loop
End Sub

B5:G7 is some dynamic data from other database which change
irregularly. my code makes it copy and paste in a enormous frequency.
what i want to realise is to make it copy every 5 seconds, in order to
sotck the data on a regular base.

just started VB learning and I have a very short period to make this
realised. So hope I can get some help.

Thanks a lot in advance



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default About my looping

On Jul 11, 3:56 pm, "Bernie Deitrick" <deitbe @ consumer dot org
wrote:
Jonathan,

You would be better off using the OnTime method to control the data write.

Use the code below, and run StartIt to start the process, and StopIt to stop the process. This will
put the date and time into column A next to the stored values for record-keeping.

HTH,
Bernie
MS Excel MVP

Dim NextTime As Date

Sub StartIt()
Update
End Sub

Sub Update()
Dim myCell As Range
NextTime = Time + TimeValue("00:00:05")
Range("B5:G7").Copy
Set myCell = Cells(Rows.Count, 2).End(xlUp)(2)
myCell.PasteSpecial _
Paste:=xlPasteValues
With myCell.Offset(0, -1).Resize(3)
.Value = Now
.NumberFormat = "mm/dd/yy hh:mm:ss"
End With
Application.OnTime NextTime, "Update"
End Sub

Sub StopIt()
On Error Resume Next
Application.OnTime NextTime, "Update", schedule:=False
End Sub

"jonathan" wrote in message

ps.com...



Just started VB for some functions that I would love to realise. but
the onlyu thing that I have for the moment is


Sub Macro2()
'
' Macro2 Macro
' Macro recorded 11/07/2007 by STD03
'


'
i = 0
Do While Now() 39269
Range("B5:G7").Select
Selection.Copy
Range("B13").Select
ActiveCell.Offset(i, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
i = i + 3
Loop
End Sub


B5:G7 is some dynamic data from other database which change
irregularly. my code makes it copy and paste in a enormous frequency.
what i want to realise is to make it copy every 5 seconds, in order to
sotck the data on a regular base.


just started VB learning and I have a very short period to make this
realised. So hope I can get some help.


Thanks a lot in advance- Hide quoted text -


- Show quoted text -


Thanks so much.
it works perfectly so far.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default About my looping

Sorry to hear about your looping
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
Looping David T Excel Discussion (Misc queries) 2 August 30th 06 10:51 PM
Looping help please Christy Excel Programming 4 July 14th 06 06:52 PM
looping Neal Excel Programming 2 May 19th 06 10:27 PM
Looping scottwilsonx[_52_] Excel Programming 1 October 5th 04 04:13 PM
Looping Louise[_4_] Excel Programming 1 September 10th 04 04:57 PM


All times are GMT +1. The time now is 08:24 AM.

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

About Us

"It's about Microsoft Excel"