Public s As Integer
Private Sub commandbutton_Click()
If s = 0 Then
commandbutton.Caption = "Check"
MsgBox "Click Yes To Proceed, Esc to abort"
roll_button.Caption = "Click again to proceed"
s = 1
ElseIf s = 1 Then
MsgBox "Confirmation: Macro To Run?"
commandbutton.Caption = "Running"
Call execution 'calling subrouting to execute
s = 0
End If
End Sub
Private Sub button_dblClick(ByVal Cancel As MSForms.ReturnBoolean)
MsgBox "Click OK to proceed, Esc to cancel"
Call execution_code
End Sub
Range("A4:X4").Select
Selection.Copy
Range("Y4").Select
Selection.PasteSpecial Paste:=xlPasteValues
Sheets("Sheet1").Range("A4:X4").Copy
Sheets("Sheet1").Range("Y4").PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
Sheets("Sheet1").Activate
Range("A4:X4").Copy
Range("Y4").PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
Sheets("sheet1").Select
Option Explicit
Private Sub CommandButton1_Click()
If CommandButton1.Caption = "Check" Then
If MsgBox("Click OK To Proceed else Cancel", vbOKCancel) = vbOK Then _
CommandButton1.Caption = "Click again to proceed"
Else
CommandButton1.Caption = "Check"
If MsgBox("Confirmation: Macro To Run?", vbOKCancel) = vbOK Then _
Call Execution 'calling subrouting to execute
End If
End Sub
Sub Execution()
End Sub
Hi, Thanks for your replies.
I have done something along the lines suggested by Richard:
Code:Public s As Integer Private Sub commandbutton_Click() If s = 0 Then roll_button.Caption = "Check" MsgBox "Click Yes To Proceed, Esc to abort" roll_button.Caption = "Click again to proceed" s = 1 ElseIf s = 1 Then MsgBox "Confirmation: Macro To Run?" roll_button.Caption = "Running" Call execution 'calling subrouting to execute s = 0 End If End Sub
This overcomes the problem of accidentally pressing the macro control button, by prompting the user for confirmation. The problem is that when I call my subrouting to execute the macro, copy>paste operations in this macro that once worked fine, now kick up errors. In fact, I have noticed that any form of .select, .value, .copy operation now does not work. I really don't know what I am doing wrong. I tried to add a basic copy>paste instruction to go back to basics, and this executed fine for some reason. So it seems that the code that was present prior to adding sub commandbutton_Click() has suddenly become invalidated in some way. Strange or what?
vcoder