Forum Discussion

chowell97's avatar
chowell97
Copper Contributor
Feb 26, 2023
Solved

Changing table name breaks VBA code

Hello,   I have an excel sheet that is used as a template to create additional sheets in an excel workbook. This sheet has a table named Master_Template.   There is VBA code that references the ...
  • HansVogelaar's avatar
    Feb 26, 2023

    chowell97 

    Does each sheet have only one table? If so, you could use code like this:

        Dim Tbl As ListObject
        Dim Module As Range
        Dim MACHINE As Range
    
        Set Tbl = ActiveSheet.ListObjects(1)
        Set Module = Tbl.ListColumns("TYPE").DataBodyRange
        Set MACHINE = Tbl.ListColumns("MACHINE").DataBodyRange

     

Resources