Macro VBA Run-Time Error 1004 --- Macro will execute twice flawlessly, then throws a 'RTE 1004' error.

RLB1127

New Member
Joined
Sep 14, 2016
Messages
11
I have a 'reset' macro that toggles a workbook view (hiding & unhiding worksheets). It runs great 2 times and then fails, but I don't have enough experience to understand why or fix it. There are (3) macros in my workbook: Reset, KView, BView. Any help appreciated.

Reset Macro is as follows:

Sub ResetButton()
'
' ResetButton Macro
'Sub clearslcr()
Dim slcr As SlicerCache
Dim sl As Slicer


For Each slcr In ActiveWorkbook.SlicerCaches
For Each sl In slcr.Slicers

slcr.ClearManualFilter

Next sl
Next slcr

Sheets("Item Distribution").Select
Cells.Select
Selection.EntireRow.Hidden = False
Selection.EntireColumn.Hidden = False
Range("B8").Select
Sheets(Array("Item Distribution", "Item % Distribution")).Select
Sheets("Item Distribution").Activate
ActiveWindow.SelectedSheets.Visible = False
Sheets("Distribution Grid Cover").Select
Range("B3:O3").Select
End Sub
Sub KView()
'
' KView Macro
'

'
Sheets("Distribution Grid Cover").Select
Sheets("Item Distribution").Visible = True
Sheets("Distribution Grid Cover").Select
Sheets("Item % Distribution").Visible = True
Sheets("Item Distribution").Select
Rows("1:6").Select
Range("B1").Activate
Selection.EntireRow.Hidden = True
Range("B8").Select
Sheets("Item % Distribution").Select
Range("B8").Select
Sheets("Item Distribution").Select
End Sub
Sub BView()
'
' BView Macro
'

'
Sheets("Distribution Grid Cover").Select
Sheets("Item Distribution").Visible = True
Sheets("Distribution Grid Cover").Select
Sheets("Item % Distribution").Visible = True
Sheets("Item Distribution").Select
Columns("A:A").Select
Selection.EntireColumn.Hidden = True
Range("B8").Select
End Sub
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
If you debug when it throws the error it will tell you which line is causing the problem.

Best guess would be that you're trying to select a sheet which is hidden.
 
Upvote 0

Forum statistics

Threads
1,214,879
Messages
6,122,065
Members
449,064
Latest member
scottdog129

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