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

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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