Carbuyer0002
New Member
- Joined
- Apr 23, 2018
- Messages
- 2
Hi all,
From reading through this site, I've written a macro to copy an input from a list, paste it into a model that calculates based on data pulled in from an external source, and then paste specials the results back to the list. However-- when I run it, the macro runs faster than excel can pull in the external data so the pasted results are all inaccurate. I think what it needs is a way to pause the macro to give excel time to catch up before continuing, and from reading other posts maybe something this is the ticket:
" Application.OnTime Now + TimeValue("00:00:10") "
But it's not working. I don't think I am nesting it the right way. Any help would be greatly appreciated! See Below:
Sub Macro3()
'
Dim i As Integer
For i = 1 To 100
Range("A" & i).Select
Selection.Copy
Range("F1").Select
ActiveSheet.Paste
Application.OnTime Now + TimeValue("00:00:10")
Range("G1:H1").Select
Application.CutCopyMode = False
Selection.Copy
Range("B" & i).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Range("A" & i + 1).Select
Application.CutCopyMode = False
Selection.Copy
Range("F1").Select
ActiveSheet.Paste
Application.OnTime Now + TimeValue("00:00:10")
Range("G1:H1").Select
Application.CutCopyMode = False
Selection.Copy
Range("B" & i + 1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Next i
End Sub
From reading through this site, I've written a macro to copy an input from a list, paste it into a model that calculates based on data pulled in from an external source, and then paste specials the results back to the list. However-- when I run it, the macro runs faster than excel can pull in the external data so the pasted results are all inaccurate. I think what it needs is a way to pause the macro to give excel time to catch up before continuing, and from reading other posts maybe something this is the ticket:
" Application.OnTime Now + TimeValue("00:00:10") "
But it's not working. I don't think I am nesting it the right way. Any help would be greatly appreciated! See Below:
Sub Macro3()
'
Dim i As Integer
For i = 1 To 100
Range("A" & i).Select
Selection.Copy
Range("F1").Select
ActiveSheet.Paste
Application.OnTime Now + TimeValue("00:00:10")
Range("G1:H1").Select
Application.CutCopyMode = False
Selection.Copy
Range("B" & i).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Range("A" & i + 1).Select
Application.CutCopyMode = False
Selection.Copy
Range("F1").Select
ActiveSheet.Paste
Application.OnTime Now + TimeValue("00:00:10")
Range("G1:H1").Select
Application.CutCopyMode = False
Selection.Copy
Range("B" & i + 1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Next i
End Sub