Rubber Beaked Woodpecker
Board Regular
- Joined
- Aug 30, 2015
- Messages
- 205
- Office Version
- 2021
I have a macro that I need to run every 5 seconds until I manually need to stop the macro.
I have been playing around with Application on time method but no joy
The code is as following:
On advice on how to achieve this please.
Many thanks
RBW
I have been playing around with Application on time method but no joy
The code is as following:
VBA Code:
Sub logBalance()
Dim source As Worksheet
Dim destination As Worksheet
Dim emptyColumn As Long
Set source = Sheets("Sheet8")
Set destination = Sheets("Sheet1")
source.Range("D556:D567").Copy
destination.Range("O5:O16").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
source.Range("D543:D554").Copy
destination.Range("Y5:Y16").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
source.Range("D540:D567").Copy
emptyColumn = destination.Cells(2, destination.Columns.Count).End(xlToLeft).Column
If IsEmpty(destination.Range("Z2")) Then
destination.Cells(1, 1).PasteSpecial Transpose:=True
Else
emptyColumn = emptyColumn + 1
destination.Cells(2, emptyColumn).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End If
destination.Range("X4:X44").Copy
emptyColumn = destination.Cells(31, destination.Columns.Count).End(xlToLeft).Column
If IsEmpty(destination.Range("Z31")) Then
destination.Cells(1, 1).PasteSpecial Transpose:=True
Else
emptyColumn = emptyColumn + 1
destination.Cells(31, emptyColumn).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
source.Range("D540:D567").Delete Shift:=xlToLeft
End If
End Sub
On advice on how to achieve this please.
Many thanks
RBW