TheRobRush
New Member
- Joined
- Nov 5, 2018
- Messages
- 39
Would like to make a VBA private sub that runs a column of data on change and combines in another column the time from the cell + current DAY + AM/PM (value from a matching cell in another column)
If it makes it easier it can also pull date from a third column.
code below is what I started with. It gives screenshot results.
no matter how I try to change it I keep getting type mismatch if I try to add more than current RNG.Value into output
Anyone got time to help?
https://1drv.ms/u/s!AiJyNsDWxYqVt2w16Imk-U0FLvhd
If it makes it easier it can also pull date from a third column.
code below is what I started with. It gives screenshot results.
no matter how I try to change it I keep getting type mismatch if I try to add more than current RNG.Value into output
Anyone got time to help?
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim WorkRng As Range
Dim Rng As Range
Dim xOffsetColumn As Integer
Set WorkRng = Intersect(Application.ActiveSheet.Range("C:C"), Target)
xOffsetColumn = 6
If Not WorkRng Is Nothing Then
Application.EnableEvents = False
For Each Rng In WorkRng
If Not VBA.IsEmpty(Rng.Value) Then
Rng.Offset(0, xOffsetColumn).Value = Rng.Value
Rng.Offset(0, xOffsetColumn).NumberFormat = "dd-mm-yyyy, hh:mm:ss"
Else
Rng.Offset(0, xOffsetColumn).ClearContents
End If
Next
Application.EnableEvents = True
End If
End Sub
https://1drv.ms/u/s!AiJyNsDWxYqVt2w16Imk-U0FLvhd