How to replace a button with another after message box selection

edwardzbrown

New Member
Joined
Jun 12, 2017
Messages
20
Hello,

I have a setup where: a button function will bring in a row from a template sheet. After that row in inserted above the button, I want one of two things to happen. Either that button deletes itself, and I can have the new button copied over OR I want that button to replace itself with the other button that I have. Like replace this module with this module. Sample of where I'm at below:

Sub Button24_Click() 'Arch Review
' Add Revision Button. Inserts another revision row at the bottom of each entry field where the button is located.


'Variable Declaration
Dim OutPut As Integer
'Example of vbYesNoCancel
OutPut = MsgBox("Does Architect Accept CNA Entry? ''Yes'' will indicate CNA entry as accepted. ''No'' will create Architect Revision Field.", vbQuestion + vbYesNoCancel, "Architect Entry Only")


If OutPut = 6 Then
'Output = 6(Yes)
MsgBox "New Entry Range Created"
MsgBox "CNA input has been marked as Accepted", vbInformation, "A-SCR2"
'I'll make code here eventually to change the color of the font on the button from RED to GREEN as an indication that the entry was reviewed and accepted.

ElseIf OutPut = 7 Then
'Output = 7(No)


' Mainlineup Macro
Dim b As Object, cs As Integer
Set b = ActiveSheet.Buttons(Application.Caller)
With b.TopLeftCell
cs = .Row
End With
'Insert template Entry from another Work Sheet
Worksheets("Templates").Rows("18:19").Copy
ActiveSheet.Rows(cs).Insert Shift:=xlDown

'delete row above - This isn't really working for me, but I keep it here in case this is what I need to make this work out the way I want.
' ActiveSheet.Rows(cs).EntireRow.Delete


'delete myself - This is the part I need help with. I want this button to go away, so that it won't overlap the new button I just copied from a template, or to swap this button with the button I want to occupy this space now.

MsgBox "New Architect Revision Field Created", vbInformation, "A-SCR2"

Else
'Cancel. No need for anything. Else nothing.
End If
End Sub


Thanks for all your help!
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
I wouldn't delete the button... I'd change the caption and use an IF statement to run this or that depending on the caption.
 
Upvote 0

Forum statistics

Threads
1,214,908
Messages
6,122,187
Members
449,071
Latest member
cdnMech

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top