Need VBA Code to work with Excel Tables

Eric Penfold

Active Member
Joined
Nov 19, 2021
Messages
431
Office Version
  1. 365
Platform
  1. Windows
  2. 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.
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
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.

Forum statistics

Threads
1,224,847
Messages
6,181,318
Members
453,032
Latest member
Pauh

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