Calling macro with arguments

rlpowers45

New Member
Joined
Oct 4, 2022
Messages
7
Office Version
  1. 365
Platform
  1. Windows
I created a macro to run from buttons over a set of columns to filter for Xs in the column as below

Sub SetFilter(Col)
Call Unfilter
Worksheets("Manuals QC").Range("A3").AutoFilter field:=Col, Criteria1:="X"
End Sub

(Note: Unfilter() clears all the filters)
When I originally assigned the macro to the button I put quotes around it and include the column number, e.g., "Sheet6.SetFilter(7)"
This worked great but has suddenly stopped working with an Excel error message
1664920207280.png


My work around is to create multiple subs to assign to each button but it's irritating to working code suddenly stop working. Am I missing something? Did a new Excel release occur that changed this?

Thanks in advance for advice and consolation. :)
 
Build I am using MS365 and no settings come to mind that would impact that.
If you use the file that you put on the Dropbox does the button on Column G work ?
No, it gives the error message shown in the initial posting--can't run the macro. I can't think of anything I've changed. I have auto update turned on-Version 2209 Build 15629.20156
 
Upvote 0

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
In your Trust Center settings, do you have the option to enable Excel 4.0 macros checked? You need it (and you'll need to reopen the file after changing it).
 
Upvote 0
Good call, Rory! Seems to be fixed now. That may be an issue for some users that are having trouble with the macros in the rest of the app. What other Trust Center settings are required/do you recommend for working with macro-spreadsheets? Is there a tutorial somewhere that discusses this issue?

Thanks, Rory, and thanks to everyone for your inputs.
 
Upvote 0
That's the only new one that I know of, other than the new MOTW security flag that requires you to unblock files received from external sources.
 
Upvote 0

Forum statistics

Threads
1,214,983
Messages
6,122,583
Members
449,089
Latest member
Motoracer88

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