Hey guys,
I have not been using VBA for very long so forgive me if this code is messy!
My excel sheet has a list of risks that are either applicable or not applicable.
Here is the code for Not Applicable:
The button "ReverseButton1" that was just created needs to delete itself if pressed, along with unhiding and hiding rows:
But it just doesn't delete. I've tried a few different codes from other forums but nothing seems to work. A lot of issues with Objects not being defined.
PS I'm gonna have 80 of these buttons, so a total button wipe is a no go. As I know where the button would be, I've tried deleting buttons within a range, but I'm way over my head to be honest!
A little help would be amazing!
Cheers,
David
I have not been using VBA for very long so forgive me if this code is messy!
My excel sheet has a list of risks that are either applicable or not applicable.
Here is the code for Not Applicable:
VBA Code:
Sub Not_Applicable_1()
Dim btn As Button
Application.ScreenUpdating = False
Dim t As Range
Set t = ActiveSheet.Range(Cells(18, 12), Cells(18, 12))
Set btn = ActiveSheet.Buttons.Add(t.Left, t.Top, t.Width, t.Height)
With btn
.OnAction = "Reverse1"
.Caption = "Reverse"
.Name = "ReverseButton1"
End With
Application.ScreenUpdating = True
Sheets("Risk Assessment").Range("B18:L18").Copy
ActiveSheet.Paste Destination:=Range("B81")
Sheets("Risk Assessment").Range("B81").EntireRow.Hidden = False
Sheets("Risk Assessment").Range("18:18").EntireRow.Hidden = True
Sheets("Pretend Other Sheet").Select
Range("B1:K1").Select
Range("B1:K1").Select
Selection.Clear
Sheets("Risk Assessment").Select
Range("A1").ClearOutline
End Sub
The button "ReverseButton1" that was just created needs to delete itself if pressed, along with unhiding and hiding rows:
VBA Code:
Sub Reverse1()
Rows(81).EntireRow.Hidden = True
Sheets("Risk Assessment").Range("18:18").EntireRow.Hidden = False
Sheets("Risk Assessment").Range("B81").EntireRow.Hidden = True
ActiveSheet.Shapes.Range(Array("ReverseButton1")).Select
Selection.Delete
End Sub
But it just doesn't delete. I've tried a few different codes from other forums but nothing seems to work. A lot of issues with Objects not being defined.
PS I'm gonna have 80 of these buttons, so a total button wipe is a no go. As I know where the button would be, I've tried deleting buttons within a range, but I'm way over my head to be honest!
A little help would be amazing!
Cheers,
David