Use VBA to select a cell in a column, and then delete it.

smith914

New Member
Joined
Aug 13, 2013
Messages
2
I currently have the code below;
Code:
Private Sub CommandButton1_Click()
Dim Response As VbMsgBoxResult
 Response = MsgBox("Are you sure you want to delete this waiting list?", vbExclamation + vbYesNo)
If Response = vbNo Then Exit Sub
 Sheets("Home").Select
 Sheets(ComboBox1.Value).Delete
 Unload Me
 MsgBox "The worksheet has been deleted", vbInformation
End Sub
Which selects a sheet based on a combo box and then deletes it.

The data that goes into ComboBox1 is based on the names of the spreadsheet, so what I would also like to be able to do is to delete the data in the cell that contains the spreadsheet name.

I don't know if it would be easier to delete the data in the cell and then re-sort the list to remove the gap, that would appear, or if I should delete the whole row?

The next bit of code is what I use to auto sort the list;

Code:
Columns("N:N").SelectSelection.Sort Key1:=Range("N1"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.

Forum statistics

Threads
1,214,920
Messages
6,122,279
Members
449,075
Latest member
staticfluids

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