Combo box as autofilter (Macro to hide rows)

rebeto13

Board Regular
Joined
Feb 22, 2006
Messages
68
Hi, I'm using a combo box to work as an autofilter, but since there's totals included I'm using it. I've set the code of it as

If ComboBox1.Value = 710 Then
Rows("16:244").Hidden = True
End If

However when I run it I get an error message, even though the rows are hidden. Is there a way to disable the debug dialog box brought up??? Or is there another way to write the code to make it work?

Thanks
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

HalfAce

MrExcel MVP
Joined
Apr 6, 2003
Messages
9,454
Hello rebeto13,
Is there a way to disable the debug dialog box
Yes, you can include the line:
Application.DisplayAlerts = False
Just make sure you include the line:
Application.DisplayAlerts = True before the end of your sub.

However, it is far more preferable to address/eliminate the error than to just force
vba to ignore it. :wink:
What line of code is highlighted when you get the error?
What does the rest of your code look like?
Is this a combobox control on a userform, or is it planted directly on the worksheet?
 

rebeto13

Board Regular
Joined
Feb 22, 2006
Messages
68
Hi This is the line that's being highlited as having an error.

Rows("16:244").Hidden = True

The combo box is in the worksheet, not in a userform.

Thanks
 

HalfAce

MrExcel MVP
Joined
Apr 6, 2003
Messages
9,454
Is there more going on than just that bit of code? It's working fine for me.

Is the sheet protected or something? If so, try this.
Code:
Private Sub ComboBox1_Change()
If ComboBox1.Value = 710 Then
  ActiveSheet.Unprotect
  Rows("16:244").Hidden = True
  ActiveSheet.Protect
End If
End Sub

If that's not it then what is the actual error number and message displayed?
 

Forum statistics

Threads
1,141,630
Messages
5,707,511
Members
421,511
Latest member
mgroah1

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
Top