SlinkRN
Well-known Member
- Joined
- Oct 29, 2002
- Messages
- 715
Good morning! I have an Excel Workbook that is shared and I created a Toggle button that users can click to signify that the workbook is currently being used and others should wait until the toggle button turns green. Unfortunately, somehow the shape automatically is being copied and pasted on top of the current shape occasionally which makes the toggle button not function until I delete the copies. It only happens sometimes, so I'm wondering if 2 users click on the button at the same time it makes that copy. Can anyone see why the copy is being pasted over the shape? Here is the code:
VBA Code:
Sub Toggle()
If Range("ToggleActive") = 0 Then
ActiveSheet.Shapes.Range(Array("CodeActive")).Select
With Selection.ShapeRange.Fill
.Visible = msoTrue
.ForeColor.RGB = RGB(255, 51, 51)
.Transparency = 0
.Solid
End With
Sheets("Main").Unprotect "password"
Selection.ShapeRange(1).TextFrame2.TextRange.Characters.Text = _
"Someone is using functions (clicking on name or using buttons) right now - please wait."
Sheets("Main").Protect "password"
Range("ToggleActive") = 1
Exit Sub
End If
If Range("ToggleActive") = 1 Then
ActiveSheet.Shapes.Range(Array("CodeActive")).Select
With Selection.ShapeRange.Fill
.Visible = msoTrue
.ForeColor.RGB = RGB(45, 134, 45)
.Transparency = 0
.Solid
End With
Sheets("Main").Unprotect "password"
Selection.ShapeRange(1).TextFrame2.TextRange.Characters.Text = _
"Nobody is using functions (clicking on name or using buttons) right now - please click this button to notify others before using functions."
Sheets("Main").Protect "password"
Range("ToggleActive") = 0
End If
End Sub