VBA Code help for hiding rows and column based on dropdown selections

suzette0735

New Member
Joined
Jul 12, 2023
Messages
18
Office Version
  1. 365
Platform
  1. Windows
Hi,
I know very little about VBA, but believe i need this for the project I am working on. I am trying to hide certain rows and columns based in the drop down selection. The drop down selection is in merged cellsf2-g3. The Drop down selections are Select Sheet, Estimate/Bid sheet, Master Ticket, Warehouse/Installer Copy, Accounting Copy.

I would like the sheet to have almost all rows hidden when the select sheet is chosen and when the document is first open this is where i want it to be. I want rows 13-92 hidden.

For the Estimate bid sheet i need columns N-R hidden

For the master ticket i need these rows hidden, 15,16,23,24,31,32,39,40,47,48,55,56,63,67,70,71,72,73, and columns m-r hidden.

For the warehouse/installer copy i need these rows hidden, 15,16,23,24,31,32,39,40,47,48,55,56,63,67,70,71,72,73, and columns j-r hidden.

For the Accounting copy i do not want anything hidden.

Can anyone please help me? I have watched some videos but cannot seem to get it right and where exactly in VBA is the right place to insert the codes for all these to run properly. Thankyou so much!!
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
in the cboBox_afterupdate event, run what rows/columns to hide

Code:
public cboBox_afterupdate()
 RunHideRow
endif


Public Sub RunHideRow()

UnhideAll

Select Case cboBox
   Case "Master Ticket"
      Rows("15:16").EntireRow.Hidden = True
      Rows("23:24").EntireRow.Hidden = True
        'etc...
      Columns("M:R").EntireColumn.Hidden = True
        'etc...
      
      
   Case "warehouse/installer"
      Rows("15:16").EntireRow.Hidden = True
      Rows("23:24").EntireRow.Hidden = True
        'etc...
      Columns("J:R").EntireColumn.Hidden = True
     
   Case "Account"
     'show all
End Select
End Sub


Private Sub UnhideAll()
    Cells.Select
    Selection.EntireRow.Hidden = False
    Selection.Entirecolumn.Hidden = False
    Range("A1").Select
End Sub
 
Upvote 0
in the cboBox_afterupdate event, run what rows/columns to hide

Code:
public cboBox_afterupdate()
 RunHideRow
endif


Public Sub RunHideRow()

UnhideAll

Select Case cboBox
   Case "Master Ticket"
      Rows("15:16").EntireRow.Hidden = True
      Rows("23:24").EntireRow.Hidden = True
        'etc...
      Columns("M:R").EntireColumn.Hidden = True
        'etc...
     
     
   Case "warehouse/installer"
      Rows("15:16").EntireRow.Hidden = True
      Rows("23:24").EntireRow.Hidden = True
        'etc...
      Columns("J:R").EntireColumn.Hidden = True
    
   Case "Account"
     'show all
End Select
End Sub


Private Sub UnhideAll()
    Cells.Select
    Selection.EntireRow.Hidden = False
    Selection.Entirecolumn.Hidden = False
    Range("A1").Select
End Sub
Thank you very much and I apologize in advance for my VBA lack of knowledge. I have put in the code into the sheet where I need it, but it does not do anything. Is this where i need to put it? Also do i need to hit run afterwards?
I'll send a screen shot. Also, what part shows when "Select Sheet" is selected that rows 13-92 are hidden?
 

Attachments

  • Screenshot 2023-09-02 vba.png
    Screenshot 2023-09-02 vba.png
    252.8 KB · Views: 7
Upvote 0

Forum statistics

Threads
1,215,071
Messages
6,122,964
Members
449,094
Latest member
Anshu121

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