Trying to group/ungroup named ranged columns on another tab after making updates to ActiveX drop down on input tab

DRuss322

New Member
Joined
Nov 11, 2020
Messages
1
Office Version
  1. 365
Platform
  1. Windows
I'm trying to group/ungroup columns (named range) based on activeX drop down but getting errors. I get an error code "compile error: sub or function not defined." Here's my code that I currently have in a module:

VBA Code:
Public Sub DropDown12_Change()
'drop box named 'dropdown12

     Application.ScreenUpdating = False
   
    'Worksheet("Rolling Forecast").Outline.ShowLevels RowLevels:=0, ColumnLevels:=1
   
    Select Case ActiveSheet.Range("I11").Value
'drop down changes value in cell I11 on input tab
   
        Case "1"
'group all
            If Worksheet("Rolling Forecast").Columns("JanRollingFcst").EntireColumn.Hidden Then
                Worksheet("Rolling Forecast").Columns("JanRollingFcst").EntireColumn.ShowDetail = False
            If Worksheet("Rolling Forecast").Columns("FebRollingFcst").EntireColumn.Hidden Then
                Worksheet("Rolling Forecast").Columns("FebRollingFcst").EntireColumn.ShowDetail = False
            If Worksheet("Rolling Forecast").Columns("MarRollingFcst").EntireColumn.Hidden Then
               Worksheet("Rolling Forecast").Columns("MarRollingFcst").EntireColumn.ShowDetail = False
            If Worksheet("Rolling Forecast").Columns("AprRollingFcst").EntireColumn.Hidden Then
               Worksheet("Rolling Forecast").Columns("AprRollingFcst").EntireColumn.ShowDetail = False
            If Worksheet("Rolling Forecast").Columns("MayRollingFcst").EntireColumn.Hidden Then
               Worksheet("Rolling Forecast").Columns("MayRollingFcst").EntireColumn.ShowDetail = False
            If Worksheet("Rolling Forecast").Columns("JunRollingFcst").EntireColumn.Hidden Then
               Worksheet("Rolling Forecast").Columns("JunRollingFcst").EntireColumn.ShowDetail = False
            If Worksheet("Rolling Forecast").Columns("JulRollingFcst").EntireColumn.Hidden Then
               Worksheet("Rolling Forecast").Columns("JulRollingFcst").EntireColumn.ShowDetail = False
            If Worksheet("Rolling Forecast").Columns("AugRollingFcst").EntireColumn.Hidden Then
               Worksheet("Rolling Forecast").Columns("AugRollingFcst").EntireColumn.ShowDetail = False
            If Worksheet("Rolling Forecast").Columns("SepRollingFcst").EntireColumn.Hidden Then
               Worksheet("Rolling Forecast").Columns("SepRollingFcst").EntireColumn.ShowDetail = False
            If Worksheet("Rolling Forecast").Columns("OctRollingFcst").EntireColumn.Hidden Then
               Worksheet("Rolling Forecast").Columns("OctRollingFcst").EntireColumn.ShowDetail = False
            If Worksheet("Rolling Forecast").Columns("NovRollingFcst").EntireColumn.Hidden Then
               Worksheet("Rolling Forecast").Columns("NovRollingFcst").EntireColumn.ShowDetail = False
            If Worksheet("Rolling Forecast").Columns("DecRollingFcst").EntireColumn.Hidden Then
               Worksheet("Rolling Forecast").Columns("DecRollingFcst").EntireColumn.ShowDetail = False
        Case "2"
'group all except JanRollingFcst
            If Worksheet("Rolling Forecast").Columns("JanRollingFcst").EntireColumn.Hidden Then
               Worksheet("Rolling Forecast").Columns("JanRollingFcst").EntireColumn.ShowDetail = True
            If Worksheet("Rolling Forecast").Columns("FebRollingFcst").EntireColumn.Hidden Then
               Worksheet("Rolling Forecast").Columns("FebRollingFcst").EntireColumn.ShowDetail = False
            If Worksheet("Rolling Forecast").Columns("MarRollingFcst").EntireColumn.Hidden Then
               Worksheet("Rolling Forecast").Columns("MarRollingFcst").EntireColumn.ShowDetail = False
            If Worksheet("Rolling Forecast").Columns("AprRollingFcst").EntireColumn.Hidden Then
               Worksheet("Rolling Forecast").Columns("AprRollingFcst").EntireColumn.ShowDetail = False
            If Worksheet("Rolling Forecast").Columns("MayRollingFcst").EntireColumn.Hidden Then
               Worksheet("Rolling Forecast").Columns("MayRollingFcst").EntireColumn.ShowDetail = False
            If Worksheet("Rolling Forecast").Columns("JunRollingFcst").EntireColumn.Hidden Then
               Worksheet("Rolling Forecast").Columns("JunRollingFcst").EntireColumn.ShowDetail = False
            If Worksheet("Rolling Forecast").Columns("JulRollingFcst").EntireColumn.Hidden Then
               Worksheet("Rolling Forecast").Columns("JulRollingFcst").EntireColumn.ShowDetail = False
            If Worksheet("Rolling Forecast").Columns("AugRollingFcst").EntireColumn.Hidden Then
               Worksheet("Rolling Forecast").Columns("AugRollingFcst").EntireColumn.ShowDetail = False
            If Worksheet("Rolling Forecast").Columns("SepRollingFcst").EntireColumn.Hidden Then
               Worksheet("Rolling Forecast").Columns("SepRollingFcst").EntireColumn.ShowDetail = False
            If Worksheet("Rolling Forecast").Columns("OctRollingFcst").EntireColumn.Hidden Then
               Worksheet("Rolling Forecast").Columns("OctRollingFcst").EntireColumn.ShowDetail = False
            If Worksheet("Rolling Forecast").Columns("NovRollingFcst").EntireColumn.Hidden Then
               Worksheet("Rolling Forecast").Columns("NovRollingFcst").EntireColumn.ShowDetail = False
            If Worksheet("Rolling Forecast").Columns("DecRollingFcst").EntireColumn.Hidden Then
               Worksheet("Rolling Forecast").Columns("DecRollingFcst").EntireColumn.ShowDetail = False
    End Select
   
    Application.ScreenUpdating = True

End Sub
 
Last edited by a moderator:

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Welcome to the MrExcel board!
"compile error: sub or function not defined."

Not sure it is the only problem but
Rich (BB code):
Worksheet("Rolling Forecast")
should be this throughout your code
Rich (BB code):
Worksheets("Rolling Forecast")
 
Upvote 0

Forum statistics

Threads
1,215,810
Messages
6,127,016
Members
449,351
Latest member
Sylvine

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