sashapixie
Board Regular
- Joined
- Aug 29, 2013
- Messages
- 71
- Office Version
- 365
- Platform
- Windows
Hi
I have some VBA to insert / update a column on the active row when changes are made within a range on the active row. The vba is working when I use cell references, however when I use table named ranges it errors.
Private Sub Worksheet_Change(ByVal Target As Range)
'Update CRM date when cells change in CRM range
Dim CRM As Range, CRM_Rng As Range, Update_CRM As Range, CRM_l As Long, CRM_Cells As String
CRM_l = ActiveCell.Row
CRM_Cells = "mapping_table[CRM - Updated Date]" & CRM_l
Set CRM = Intersect(Application.ActiveSheet.Range("mapping_table[[CRM - Table Name (M)]:[CRM - Developer]]"), Target)
Set Update_CRM = Range(CRM_Cells)
If Not CRM Is Nothing Then
Application.EnableEvents = False
For Each CRM_Rng In CRM
If Not VBA.IsEmpty(CRM_Rng.Value) Then
Update_CRM.Value = Now
Update_CRM.NumberFormat = "dd-mm-yyyy, hh:mm:ss"
Else
Update_CRM.ClearContents
End If
Next
Application.EnableEvents = True
End If
End Sub
Can anyone help please
I have some VBA to insert / update a column on the active row when changes are made within a range on the active row. The vba is working when I use cell references, however when I use table named ranges it errors.
Private Sub Worksheet_Change(ByVal Target As Range)
'Update CRM date when cells change in CRM range
Dim CRM As Range, CRM_Rng As Range, Update_CRM As Range, CRM_l As Long, CRM_Cells As String
CRM_l = ActiveCell.Row
CRM_Cells = "mapping_table[CRM - Updated Date]" & CRM_l
Set CRM = Intersect(Application.ActiveSheet.Range("mapping_table[[CRM - Table Name (M)]:[CRM - Developer]]"), Target)
Set Update_CRM = Range(CRM_Cells)
If Not CRM Is Nothing Then
Application.EnableEvents = False
For Each CRM_Rng In CRM
If Not VBA.IsEmpty(CRM_Rng.Value) Then
Update_CRM.Value = Now
Update_CRM.NumberFormat = "dd-mm-yyyy, hh:mm:ss"
Else
Update_CRM.ClearContents
End If
Next
Application.EnableEvents = True
End If
End Sub
Can anyone help please