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

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
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?
 
Upvote 0
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
 
Upvote 0
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?
 
Upvote 0

Forum statistics

Threads
1,214,622
Messages
6,120,585
Members
448,972
Latest member
Shantanu2024

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