The attached code is not working as I would like
The wish I have is 1 button with multi functions each allowing different texts to populate the Button so I can easily see whats happening with the workbook.
By default the first Text in the Button would be "Ready" In Yellow
Then if I press on Ready, text "Running" in green would populate the button and the VBA code would run.
And if I press on Running text "Stopped" would populate the Button in red and the attached vba code would be called to Stop and here is where the screenUpdating would refresh and show me the results up to the point when stopped was pressed.
Then if I press on Stopped text "ready" would populate the Button and I would press once more to run and finish the code task.
And upon the code completion text "Completed" would be on the button and the ScreenUpdate would be True.
Hope I am not asking for a complicated Code although to me sounds like it is.
Thank you for your Help
Cheers
current code I am using
The wish I have is 1 button with multi functions each allowing different texts to populate the Button so I can easily see whats happening with the workbook.
By default the first Text in the Button would be "Ready" In Yellow
Then if I press on Ready, text "Running" in green would populate the button and the VBA code would run.
And if I press on Running text "Stopped" would populate the Button in red and the attached vba code would be called to Stop and here is where the screenUpdating would refresh and show me the results up to the point when stopped was pressed.
Then if I press on Stopped text "ready" would populate the Button and I would press once more to run and finish the code task.
And upon the code completion text "Completed" would be on the button and the ScreenUpdate would be True.
Hope I am not asking for a complicated Code although to me sounds like it is.
Thank you for your Help
Cheers
current code I am using
Code:
Sub ValueStore()
Application.EnableEvents = False
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Application.Calculation = xlCalculationManual
Dim rw As Integer
For rw = 12 To 37
Cells(rw, 1).Value = 1
Application.Calculate
Do While Application.CalculationState <> xlDone
DoEvents
Loop
Range(Cells(rw, 3), Cells(rw, 46)).Copy ' check if this is the right column to stop on
Range(Cells(rw, 3), Cells(rw, 46)).PasteSpecial (xlPasteValues)
'Range(Cells(rw, 3), Cells(rw, 46)).Value = Range(Cells(rw, 3), Cells(rw, 46)).Value
Next
Application.EnableEvents = True
Application.ScreenUpdating = True
Application.DisplayAlerts = True
Application.Calculation = xlCalculationAutomatic
End Sub
Sub Toggle()
Set shp = ActiveSheet.Shapes(1)
If shp.TextFrame.Characters.Text = "Ready" Then
With shp
.Fill.ForeColor.RGB = rgbRed
.TextFrame.Characters.Text = "Stopped"
End With
Call ValueStore
ElseIf shp.TextFrame.Characters.Text = "Stopped" Then
With shp
.Fill.ForeColor.RGB = rgbGreen
.TextFrame.Characters.Text = "Ready"
End With
End If
End Sub