writing vba to change vba module

splreece

Board Regular
Joined
May 29, 2015
Messages
72
Hi all,

In ThisWorkbook I have a simple line of code that opens a specific worksheet.

I need a way of using a button to comment out that particular line or the whole module (module called mdl_snapshot).

Is it possible as I can't find where or how to do it and I will be handing over the doc to someone less comfortable with vba then me.
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
The request is not clear. So you want the macro to run parts but not other parts? What is the determining factor(s) whether it runs which parts? Otherwise why not just comment it out with an ' apostrophe before that part of the code???
 
Upvote 0
The request is not clear. So you want the macro to run parts but not other parts? What is the determining factor(s) whether it runs which parts? Otherwise why not just comment it out with an ' apostrophe before that part of the code???

Thanks for the quick response (its me not detailing the query properly).

I am handing a dashboard onto a colleague who isn't confident with excel. (So ideally I wouldn't want them going into the vba and altering lines as they may alter the wrong bit)..

The dashboard updates monthly, and as part of the course I have a tiny sub in the workbook that OnWorkBookLoad, opens a tab called "Offline" that acts as a landing page while the dashboard is being updated.

This is manually turned on and off by commenting out the sub "mdl_offline".

My query was (as I am new to vba)....is it possible I can create a button so that when the dashboard is due for an update:
- the user clicks the offline button which removes the comment indicator ' from the "mdl_offline" sub.
- the user clicks the online button which adds the comment indicator ' to the "mdl_offline" sub.


Its not a clever sub in anyway and only controls the opening tab, so I am simply turning that sub off and on using comments to either land on landing page or not.


I hope that helps a bit.... I am not experienced with VBA so a lot of my coding is probably based on non-programmer logic which is probably different from the preferred vba logic.
 
Last edited:
Upvote 0
Rather than try to modify the code itself, why use a MsgBox to ask the question
"Is the Dashboard due to be updated"
If Yes, then trigger the update code !!!
 
Last edited:
Upvote 0
Ahh I would love to be able to.

We aren't at that level yet as most of the dashboard data comes from sources that varying in recording methods.. so I have a lot of automation but also a lot of manual copy and paste stuff (no way round that as I don't own the data or recording device......yet).


So auto updating is out... for now.
 
Upvote 0
I don't follow..
This is manually turned on and off by commenting out the sub "mdl_offline".
If you can manually comment out part of the sub, you can add a MsgBox to ask the user "do they want to proceed"...that will do the same thing.
Can't offer much more without seeing that particular sub....Can you post it ???
 
Upvote 0
You might also use a cell or defined name that the code can check before running the routine. That would be a lot simpler for an inexperienced user to change.
 
Upvote 0

Forum statistics

Threads
1,214,606
Messages
6,120,497
Members
448,967
Latest member
visheshkotha

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