miming1986
New Member
Hi,
I'm just starting to learn VBA. Can you help with the codes I need to use so column L (starting from L3) will auto-calculate (L3-C3) and so on and so forth.
Currently I have codes on my worksheet to automatically create timestamps based on data entered on columns B and J and column L should need to calculate the difference of the two. Is it also possible if the results on column L are in decimal format to two decimal places?
	
	
	
		
Thanks so much. I would really appreciate your responses.
				
			I'm just starting to learn VBA. Can you help with the codes I need to use so column L (starting from L3) will auto-calculate (L3-C3) and so on and so forth.
Currently I have codes on my worksheet to automatically create timestamps based on data entered on columns B and J and column L should need to calculate the difference of the two. Is it also possible if the results on column L are in decimal format to two decimal places?
		Code:
	
	Private Sub Worksheet_Change(ByVal Target As Excel.Range)
    Dim rCell As Range
    Dim rChange As Range
  
    On Error GoTo ErrHandler
    Set rChange = Intersect(Target, Range("B:B,J:J"))
    If Not rChange Is Nothing Then
        Application.EnableEvents = False
        For Each rCell In rChange
            If rCell > "" Then
                With rCell.Offset(0, 1)
                    .Value = Now
                    .NumberFormat = "hh:mm:ss"
                End With
            Else
                rCell.Offset(0, 1).Clear
            End If
        Next
    End If
ExitHandler:
    Set rCell = Nothing
    Set rChange = Nothing
    Application.EnableEvents = True
    Exit Sub
ErrHandler:
    MsgBox Err.Description
    Resume ExitHandler
End Sub
	Thanks so much. I would really appreciate your responses.
Attachments
			
				Last edited: