PDA

View Full Version : VBA to override all upcoming code for certain users??



GotAHeadache
04-16-2015, 03:08 AM
Hi Guys :-)

Is there a way in Excel VBA to override all code that may fire in all modules based on the username of the person using the file at that time?

For example, I have made a program for other users; when other's use it, I want it to do ScreenUpdating = False, DisplayFormulaBar = False etc. However, when I use it, I want Excel to display the formulabar etc.

The code to hide formulabar etc is in multiple Modules, so even when I unhide it, it will be hidden again, for example, when I change sheets, so I am always 'unhiding' it.

Is there a way to put in some code, so that when the code gets to eg 'DisplayFormulaBar = False', Excel says "uhoh, no, don't hide it because Frank is using me"? :-) (without having to go through all of the code to add in IF functions??)

Thanks,
GAH

snb
04-16-2015, 03:15 AM
Sub M_snb()
if environ("username")<>"Frank" then M_dimming
End Sub

Sub M_dimming()
ScreenUpdating = False
DisplayFormulaBar = False
end Sub

GotAHeadache
04-16-2015, 03:34 AM
Sub M_snb()
if environ("username")<>"Frank" then M_dimming
End Sub

Sub M_dimming()
ScreenUpdating = False
DisplayFormulaBar = False
end Sub


Thanks snb :-)

How does this work? Does it go in ThisWorkbook module?