Excel VBA - error ref tables

Hoube78

New Member
Joined
Mar 27, 2014
Messages
43
Hi,

Hope someone can help I'm getting an error on the highlighted part of the code below?

This occurs when I'm referencing a sheet by its code name and not its tab name.

Any help or advance??

Private Sub CommandButton1_Click()

Dim lngStart As Long, lngEnd As Long
lngStart = Sheet5.Range("A2").Value 'assume this is the start date
lngEnd = Sheet5.Range("A3").Value 'assume this is the end date

Application.ScreenUpdating = False
Sheet100.Visible = True
Sheet105.Visible = True

'assume you have field name / label in D29
Sheet100.Unprotect Password:="MM@MM.com"
Sheet100.Select
ActiveSheet.ListObjects("tbl_summary_1").Range.AutoFilter field:=8,
Criteria1:=">=" & lngStart, _
Operator:=xlAnd, _
Criteria2:="<=" & lngEnd

Sheet100.Protect Password:="MM@MM.com", AllowFiltering:=True
ActiveSheet.EnableSelection = xlUnlockedCells

Sheet105.Unprotect Password:="MM@MM.com"
Sheet105.Select
ActiveSheet.ListObjects("tbl_kpi").Range.AutoFilter field:=7, _
Criteria1:=">=" & lngStart, _
Operator:=xlAnd, _
Criteria2:="<=" & lngEnd

Sheet105.Protect Password:="MM@MM.com", AllowFiltering:=True
ActiveSheet.EnableSelection = xlUnlockedCells

Sheet3.Select

Sheet100.Visible = xlVeryHidden
Sheet105.Visible = xlVeryHidden
Application.ScreenUpdating = True

On Error GoTo ErrorHandler
Sheets(Range("H19").Value).Select
Exit Sub

Thanks in advance
J
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.

Forum statistics

Threads
1,223,229
Messages
6,170,881
Members
452,364
Latest member
springate

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