Change name of table from specific to universal [VBA]

Martin_H

Board Regular
Joined
Aug 26, 2020
Messages
190
Office Version
  1. 365
Platform
  1. Windows
Hi,

I am using this macro - which is assigned to custom ribbon UI button - on multiple worksheets (withing one workbook).

As you can see I am using a specific name Table1 and I would love to change it to some universal name. There is always only one table per worksheet.

Thank you!

VBA Code:
Public Sub DELETE(ByRef control As Office.IRibbonControl)

With Application
.ScreenUpdating = False

Range("Table1[[#Headers],[Machine]]").AutoFilter
ActiveSheet.ListObjects("Table1").Range.AutoFilter Field:=12, Criteria1:=Array("Machine1", "Machine2", "Machine3", "Machine4", "Machine5", ""), Operator:=xlFilterValues
ActiveSheet.ListObjects("Table1").ShowAutoFilterDropDown = False

Dim LastCell As Range
With ActiveSheet

Set LastCell = .Cells(Rows.Count, 2).End(xlUp)
.Range("D5", LastCell).sort Key1:=.Range("D1"), Order1:=xlAscending, Header:=xlYes, MatchCase:=False, Orientation:=xlTopToBottom, DataOption1:=xlSortTextAsNumbers
End With

With Range("B3").Font
.Color = -10027162: .TintAndShade = 0: .Bold = True
End With

With Range("D3,N3,O3,P3,Q3.F3").Font
.ThemeColor = xlThemeColorDark1: .TintAndShade = 0: .Bold = False
End With

Range("B2").Select

.ScreenUpdating = True
End With

End Sub
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Do you need to use a name?
Use:
Listobjects(1)
 
Upvote 0
Solution

Forum statistics

Threads
1,223,893
Messages
6,175,246
Members
452,623
Latest member
cliftonhandyman

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