Consulting

Results 1 to 3 of 3

Thread: Macro Autofill with Loop and Delay

  1. #1
    VBAX Newbie
    Joined
    Jun 2015
    Posts
    2
    Location

    Macro Autofill with Loop and Delay

    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
    Attached Files Attached Files

  2. #2
    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
    A mighty flame followeth a tiny sparkle!!



  3. #3
    VBAX Newbie
    Joined
    Jun 2015
    Posts
    2
    Location
    Thanks! works perfectly

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •