Running custom commands in any xlsx file

excelos

Well-known Member
Joined
Sep 25, 2011
Messages
591
Office Version
  1. 365
Platform
  1. Windows
Hello

How can I run custom macros/scripts/functions in any excel file I open?

For example, I want to click a button that will identify the column with the dates and filter the sheet by the current date.

I want to be able to run this code anytime and in any worksheet without having to store it as xlsm or do any change in the sheet. In other words, the code needs to be portable and 'outside of the file'.

Do you have any idea?

Ideally I would like not to use any addin but if that is the only option, is there any that you can specify your own code and can be installed in corporate Excel versions (with the relevant limitations)?

Thanks!
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
If this is just for your own use, then that is what the Excel Personal Macro Workbook is for. You can create macros there that you can run on other workbooks without having to store the macros in those workbooks.

 
Upvote 0
Thanks! Is there anything similar for JS too given that VBA will be probably replaced by JS?
 
Upvote 0
Thanks! Is there anything similar for JS too given that VBA will be probably replaced by JS?
No idea. People have been predicting the demise of VBA for a long time and I'm sure some bleeding edge types at Microsoft who look down their noses at the VBA masses would like that to happen. But VBA is is still very popular with a very large number of people.
 
Upvote 0
Thanks, I used this but I some times get a warning 'you need to unhide the worksheet before using it' i.e. the Personal worksheet. Is there a way to prevent that? I do not want to have an empty Personal worksheet visible to be able to run my personal VBA.
 
Upvote 0
Thanks, I used this but I some times get a warning 'you need to unhide the worksheet before using it' i.e. the Personal worksheet. Is there a way to prevent that? I do not want to have an empty Personal worksheet visible to be able to run my personal VBA.

That means you are doing something that is attempting to act on a worksheet in the personal macro workbook itself, which is a big mistake. The personal macro workbook is a special hidden workbook and should not be visible. Do not attempt to use any worksheets in the Personal Macro Workbook. Don't write code that references or attempts to manipulate the Personal Macro Workbook. Macros in the Personal Macro Workbook are meant to operate on other worksheets located in other workbooks. Any code using the "ThisWorkbook" object should be avoided.
 
Upvote 0

Forum statistics

Threads
1,214,990
Messages
6,122,626
Members
449,094
Latest member
bsb1122

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