PDA

View Full Version : macro to drag and fill formula til the time stamp match



AS_2011
01-08-2015, 07:56 AM
I have this WB, how to autofill formula to D:G range til the time stamp is same as cell J1

Admin
01-08-2015, 02:20 PM
Hi

In I1,

=MATCH(J1-INT(J1),C4:C47)

In H1, type 1. To stop macro type 0 in H1


Sub StartMacro()

Dim r, t As Date, i As Long

t = Now() + TimeSerial(0, 0, 5)

Application.OnTime t, "StartMacro", , True

r = [i1]
i = [h1]

If Not i = 0 Then
If Not IsError(r) Then
Range("d4:h4").AutoFill Range("d4:h4").Resize(r)
End If
Else
Debug.Print Now
Application.OnTime t, "StartMacro", , False
End If

End Sub

AS_2011
01-08-2015, 04:56 PM
I can't get it to work, I1 show #N/A when i run the macro, can use macro button to run and stop the macro?

AS_2011
01-09-2015, 11:52 AM
Admin, I think i found the problem, in the time column i am using some formula to get the time, how to add the code to change the time formula to value in your code? when the value of time format is m/dd/yyyy h:mm:ss AM/PM I1 show #N/A, but when i change the time format to h:mm:ss AM/PM, it is good,

Admin
01-09-2015, 03:35 PM
modify your formula like

=YourOriginalFormula-INT(YourOriginalFormula)

And format the cell as time