Scotthall1974
New Member
- Joined
- Mar 15, 2018
- Messages
- 5
Hello All!
I am having a tricky time figuring out why I am still getting a screen update in my VBA when I really do not want it. It will just freak out my users and lead to more questions. I have a toggle box switch in VBA that moves, changes colours and executes a sub based on the position of the toggle.
The toggle is on one password protected tab and it updates a formula on another password protected tab depending on the switch location. I have tried various locations for the screenupdating line and no matter where I put it I still get the flashes. Sometimes it takes a few runs of the toggle (VBA does not change - just toggle position) before it does, but eventually after a couple the screen updates.
The code should be unlocking all the tabs needed doing the substitutions and relocking the cells. That seems to be working fine, maybe the code is too jumpy or combersome, I only dabble in it. Any help would be greatly appreciated. Thank you all!
I am having a tricky time figuring out why I am still getting a screen update in my VBA when I really do not want it. It will just freak out my users and lead to more questions. I have a toggle box switch in VBA that moves, changes colours and executes a sub based on the position of the toggle.
The toggle is on one password protected tab and it updates a formula on another password protected tab depending on the switch location. I have tried various locations for the screenupdating line and no matter where I put it I still get the flashes. Sometimes it takes a few runs of the toggle (VBA does not change - just toggle position) before it does, but eventually after a couple the screen updates.
The code should be unlocking all the tabs needed doing the substitutions and relocking the cells. That seems to be working fine, maybe the code is too jumpy or combersome, I only dabble in it. Any help would be greatly appreciated. Thank you all!
Code:
Option Explicit
Sub Include_LNR_Materials()
Application.ScreenUpdating = False
'Select Button
Worksheets("1.0 Gen Info").Shapes("Button").Select
' Change Position, Color & Text
With Selection
.ShapeRange.IncrementLeft 53
.ShapeRange.Fill.ForeColor.RGB = RGB(0, 153, 0)
End With
'Assign OFF_BUTTON macro after changing position
Worksheets("1.0 Gen Info").Shapes("Button").OnAction = "Exclude_LNR_Materials"
'Macro to Run when switch is ON
Call YES_LNR_COSTS
'Activate some other cell after completion
Worksheets("1.0 Gen Info").Activate
Range("J51").Select
End Sub
---------------------
Sub Exclude_LNR_Materials()
Application.ScreenUpdating = False
'Select Button
Worksheets("1.0 Gen Info").Shapes("Button").Select
' Change Position, Color & Text
With Selection
.ShapeRange.IncrementLeft -53
.ShapeRange.Fill.ForeColor.RGB = RGB(255, 0, 0)
End With
'Assign ON_BUTTON macro after changing position
Worksheets("1.0 Gen Info").Shapes("Button").OnAction = "Include_LNR_Materials"
'Macro to Run when switch is OFF
Call NO_LNR_COSTS
'Activate some other cell after completion
Worksheets("1.0 Gen Info").Activate
Range("J51").Select
End Sub
-----------------------
Sub YES_LNR_COSTS()
Dim Password As String
Password = "gosislaw"
Worksheets("Summary").Unprotect Password:=Password
Worksheets("1.0 Gen Info").Unprotect Password:=Password
Worksheets("1.0 Gen Info").Range("K51").Formula = "='3.0 Material'!Z8-'3.0 Material'!V4"
Worksheets("1.0 Gen Info").Range("K52").Clear
Worksheets("1.0 Gen Info").Range("K51:K52").Font.Color = RGB(255, 255, 255)
Worksheets("Summary").Range("I8").Formula = "='3.0 Material'!Z8"
Worksheets("1.0 Gen Info").Protect Password:=Password
Worksheets("Summary").Protect Password:=Password
Application.ScreenUpdating = True
'TESTING
End Sub
------------------------
Sub NO_LNR_COSTS()
Dim Password As String
Password = "gosislaw"
Worksheets("Summary").Unprotect Password:=Password
Worksheets("1.0 Gen Info").Unprotect Password:=Password
Worksheets("1.0 Gen Info").Range("K52").Formula = "='3.0 Material'!Z8"
Worksheets("1.0 Gen Info").Range("K51").Clear
Worksheets("1.0 Gen Info").Range("K51:K52").Font.Color = RGB(255, 255, 255)
Worksheets("Summary").Range("I8").Formula = "='3.0 Material'!Z8-'3.0 Material'!V4"
Worksheets("1.0 Gen Info").Protect Password:=Password
Worksheets("Summary").Protect Password:=Password
Application.ScreenUpdating = True
'TESTING
-----------------------
End Sub
Last edited by a moderator: