VBA - Delete button to delete row from table and delete worksheet from cell reference

Lee Rabbit

New Member
Joined
Apr 30, 2020
Messages
43
Office Version
  1. 2010
Platform
  1. Windows
Good Day All,

I have created a delete button to remove data from a table.

I also want to delete the worksheet named by the cell value contained in column "B" of the data row.

I am having difficulty in linking the cell value of the row to the worksheet to delete. Still learning :)



VBA Code:
Private Sub CommandButton2_Click()

    Dim sh As Worksheet
    Set sh = ThisWorkbook.Sheets("DATA ENTRY")
    Dim it As Integer
    
    
    If ActiveCell.Row > 6 Then
      
        it = MsgBox("ARE YOU SURE YOU WANT TO DELETE THIS DRIVER?", vbQuestion + vbYesNo)
        
    If it = 7 Then Exit Sub
    
    ActiveCell.EntireRow.Delete
    
        
    End If
    
    
End Sub

A big thank you in advance to anyone who can help.

Regards,
Lee
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.

Forum statistics

Threads
1,215,066
Messages
6,122,948
Members
449,095
Latest member
nmaske

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