Combo Box Hide and Unhide using VBA Problem.

mikekhel1987

New Member
Joined
Nov 6, 2015
Messages
15
Hi Everyone need your help. I am using combo box to select a group to hide and unhide rows. below is the code that I used
Code:
Private Sub ComboBox1_Change()    Rows("11:250").Hidden = True
  Select Case ComboBox1.Value
    Case "All"
      Rows("11:250").Hidden = False
    Case "All Day"
      Rows("11:17").Hidden = False
    Case "Budgetlane"
      Rows("18").Hidden = False
    Case "NG Chain"
      Rows("19").Hidden = False
    Case "Daily Supermarket"
      Rows("20").Hidden = False
    Case "Fishermall"
      Rows("21").Hidden = False
    Case "Landers Superstore"
      Rows("22:24").Hidden = False
    Case "LCC"
      Rows("25:29").Hidden = False
    Case "Merkado"
      Rows("31:32").Hidden = False
    Case "Metro Gaisano"
      Rows("33:48").Hidden = False
    Case "Pioneer"
      Rows("49").Hidden = False
    Case "Puregold"
      Rows("50:56").Hidden = False
    Case "Robinsons"
      Rows("57:94").Hidden = False
    Case "Rustans"
      Rows("95:115").Hidden = False
    Case "S&R"
      Rows("116:126").Hidden = False
    Case "Savemore"
      Rows("127:153").Hidden = False
    Case "Shopwise"
      Rows("154:163").Hidden = False
    Case "SM Hypermarket"
      Rows("164:191").Hidden = False
    Case "SM Supermarket"
      Rows("192:224").Hidden = False
    Case "South Supermarket"
      Rows("225:232").Hidden = False
    Case "Landmark"
      Rows("233:235").Hidden = False
    Case "Waltermart"
      Rows("237:250").Hidden = False
   End Select
End Sub
but when I run the code I always get this error:
Run-time error '1004':
Unable to set Hidden property of Range Class

Can please someone help me with my problem. Any help will be greatly appriciated.

Thank You.
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Hi mikekhel1987,

As the syntax looks correct - I'm guessing the tab is protected which will throw that error if it is. If the tab is protected you'll need to add code to unprotect it, unhide the applicable row(s) (as your code currently does) and re-protect the tab.

Regards,

Robert
 
Upvote 0
Hi mikekhel1987,

As the syntax looks correct - I'm guessing the tab is protected which will throw that error if it is. If the tab is protected you'll need to add code to unprotect it, unhide the applicable row(s) (as your code currently does) and re-protect the tab.

Regards,

Robert

Hi Robert the worksheet is not protected.
 
Upvote 0
That's odd as it worked for me :confused:

What line is erring out?
 
Upvote 0
Not sure as I can run that piece of code with no issues :confused:

What happens if you manually highlight rows 11 to 250 (inclusive) on the active tab and click Hide from the shortcut menu (accessed by right-clicking)?
 
Upvote 0

Forum statistics

Threads
1,224,827
Messages
6,181,197
Members
453,021
Latest member
pingpong7117

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