merging 3 VBA scripts in 1

mwvirk

Active Member
Joined
Mar 2, 2011
Messages
295
Office Version
  1. 2016
Platform
  1. Windows
i have following script which is checking cell A and then accepting input in cell I and then filling cell L for current date and N for current time. then again taking input in cell T and filling cell U with current date (if there is some value in cell A)

Code:
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Dim irow As Long
If Not Intersect(Target, Range("I:I")) Is Nothing Then
On Error Resume Next
Application.EnableEvents = False
irow = Target.Row
'if there is a date in column L end the macro
If IsEmpty(Target) Or IsEmpty(Target.Offset(0, -8)) Then
    Target.Offset(0, 3).ClearContents
    Target.Offset(0, 5).ClearContents
    GoTo EndProc
End If
If IsDate(Target.Offset(0, 3)) Then GoTo EndProc
If Not IsEmpty(Target.Offset(0, -8)) Then
Target.Offset(0, 3) = Date
Target.Offset(0, 5) = Time
Else: GoTo EndProc
End If
End If
'---------------------------------
If Not Intersect(Target, Range("T:T")) Is Nothing Then
On Error Resume Next
Application.EnableEvents = False
irow = Target.Row
'if there is a date in column L end the macro
If IsEmpty(Target) Then
    Target.Offset(0, 1).ClearContents
        GoTo EndProc
End If
If IsDate(Target.Offset(0, 3)) Then GoTo EndProc
If Not IsEmpty(Target.Offset(0, -19)) Then
Target.Offset(0, 1) = Date
Else: GoTo EndProc
End If
End If
EndProc:
Application.EnableEvents = True
End Sub

then i have another script which is starting the clock:

Code:
Dim SchedRecalc As Date
Sub Recalc()
Range("C4").Value = Format(Time, "hh:mm:ss AM/PM")
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
Call SetTime
End Sub
<o:p></o:p>
Sub SetTime()
SchedRecalc = Now + TimeValue("00:00:01")
Application.OnTime SchedRecalc, "Recalc"
End Sub


and finally below script is to be used to stop the clock:

Code:
Sub Disable()
On Error Resume Next
Application.OnTime EarliestTime:=SchedRecalc, Procedure:="Recalc", Schedule:=False
End Sub


ok. all i need to merge all these 3 macro in 1. so, whenever i put some value in cell M and clock should start in cell W and when i put value in cell V and it should stop the clock and calculate and give me time in same cell ( W ) showing the total time since clock was running. (time when value was entered in cell V - time when value was entered in cell M = time)

pls help. thanks
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN

Forum statistics

Threads
1,224,574
Messages
6,179,628
Members
452,933
Latest member
patv

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top