Eric Penfold
Active Member
- Joined
- Nov 19, 2021
- Messages
- 431
- Office Version
- 365
- Platform
- Windows
- Mobile
I need to run VBA Code when event happens. But i can`t make the code fire up when I try to run it. Also not sure about the code to run the code in specific column see below??
The code is on a personal macro workbook.
The code is on a personal macro workbook.
VBA Code:
With ListObj
Col = Target.Column - ListObj.ListColumns(1).Range.Select
If .HeaderRowRange(Col).Value = ("Order Date") Then
Call Format_Cells(Sh)
Call BO_Drop_DownList(Sh)
End If
VBA Code:
Private WithEvents xlAppEvents As Application
Private Sub Workbook_Open()
Set xlAppEvents = Application
End Sub
Private Sub xlAppEvents_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Dim Wbk As Workbook
Dim Col As Long
Dim Sh As Worksheet
Set Wbk = ActiveWorkbook
Set Sh = Wbk.Worksheets("Data")
With Sh
Dim ListObj As ListObject
Set ListObj = .ListObjects("DataTable")
End With
If Sh.Name <> "Summary" And Sh.Name <> "Trend" And Sh.Name <> "Supplier BO" And Sh.Name <> "Diff Depot" _
And Sh.Name <> "BO WO" And Sh.Name <> "Diff Depot" Then
If Wbk.Name Like ("2023BackOrderReportT.xlsx") Then
With ListObj
Col = Target.Column - ListObj.ListColumns(1).Range.Select
If .HeaderRowRange(Col).Value = ("Order Date") Then
Call Format_Cells(Sh)
Call BO_Drop_DownList(Sh)
End If
Col = Target.Column - ListObj.ListColumns(9).Range.Select
If .HeaderRowRange(Col).Value = ("Back Order Reason Code") Then
Call BO_Drop_DownList(Sh)
End If
End If
End If
End Sub