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.
 

Some videos you may like

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.

Roderick_E

Well-known Member
Joined
Oct 13, 2007
Messages
2,051
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???
 

splreece

Board Regular
Joined
May 29, 2015
Messages
72
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:

Michael M

Well-known Member
Joined
Oct 27, 2005
Messages
19,766
Office Version
  1. 2016
  2. 2013
  3. 2007
Platform
  1. Windows
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:

splreece

Board Regular
Joined
May 29, 2015
Messages
72

ADVERTISEMENT

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.
 

Michael M

Well-known Member
Joined
Oct 27, 2005
Messages
19,766
Office Version
  1. 2016
  2. 2013
  3. 2007
Platform
  1. Windows
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 ???
 

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
36,133
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
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.
 

Watch MrExcel Video

Forum statistics

Threads
1,123,140
Messages
5,599,964
Members
414,352
Latest member
macquarie_jchan58

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