PDA

View Full Version : [SOLVED] Macro Autofill with Loop and Delay



ArthurS
06-20-2015, 02:32 AM
Hey all,

I've been looking to fix a code that fills a colom with a formula with a certain delay. See example file, colum D2. I want to copy the formula to D3, wait for 2 seconds and copy it to D4, etc. untill A and B are empty.

I tried the following but failed:


Sub ProcessData()
Dim LastRow As Long
Dim i As Long

With ActiveSheet

LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
For i = 1 To LastRow 'Lastrow to 1 Step -1

Application.WindowState = xlNormal
Selection.AutoFill Destination:=Range("E" & Rows.Count).End(xlUp).Row, Type:=xlFillDefault
Application.Wait Now() + TimeSerial(0, 0, 1)

Next i
End With
End Sub


Thanks in advance

excelliot
06-20-2015, 04:31 AM
use this code:




Sub ProcessData()
Dim LastRow As Long
Dim i As Long
With ActiveSheet

LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
For i = 3 To LastRow 'Lastrow to 1 Step -1

'Application.WindowState = xlNormal
If Cells(i, 5) = "" Then
Range(Cells(2, 4), Cells(i - 1, 4)).AutoFill Destination:=Range(Cells(2, 4), Cells(i, 4))
Application.Wait Now() + TimeSerial(0, 0, 1)
End If
Next i
End With
End Sub





Cheers!!
excelliot.com

ArthurS
06-21-2015, 10:19 PM
Thanks! works perfectly