ipbr21054
Well-known Member
- Joined
- Nov 16, 2010
- Messages
- 5,226
- Office Version
- 2007
- Platform
- Windows
Evening,
I am using the code shown below.
I have a combobox which has customers names in it.
I run the code supplied below which deletes the selected name from my worksheet & then it doesnt appear in the combobox again as you would expect.
My question relates to the code shown in Red.
I am expecting that once the name is deleted i then see this msgbox.
I expect to then see SUCESSFUL DELETION OF CUSTOMER TOM JONES
TOM JONES being the customer that was selected in the combobox.
So is my code incorrect OR is this not possible because its been deleted how will it advise you of the name if it isnt there ?
I dont see an error message etc & thought by adding the code & NameForDateEntryBox.Value would give me what i would like to see.
I am using the code shown below.
I have a combobox which has customers names in it.
I run the code supplied below which deletes the selected name from my worksheet & then it doesnt appear in the combobox again as you would expect.
My question relates to the code shown in Red.
I am expecting that once the name is deleted i then see this msgbox.
I expect to then see SUCESSFUL DELETION OF CUSTOMER TOM JONES
TOM JONES being the customer that was selected in the combobox.
So is my code incorrect OR is this not possible because its been deleted how will it advise you of the name if it isnt there ?
I dont see an error message etc & thought by adding the code & NameForDateEntryBox.Value would give me what i would like to see.
Rich (BB code):
Private Sub DeleteTestName_Click()
Dim lRow As Long, ws As Worksheet, i As Long
Set ws = Application.Worksheets("POSTAGE")
If NameForDateEntryBox.Value = "" Then
MsgBox "YOU MUST SELECT A CUSTOMER FIRST", vbCritical, "SELECT CUSTOMER FIRST MESSAGE"
Me.NameForDateEntryBox.SetFocus
Exit Sub
End If
If MsgBox("DELETE CUSTOMER " & NameForDateEntryBox.Value & " ?", vbCritical + vbYesNo + vbDefaultButton2, "DELETE CONFIRMATION MESSAGE") = vbNo Then
TextBox2.SetFocus
NameForDateEntryBox = ""
Exit Sub
Else
lRow = ws.Cells(Rows.Count, 2).End(xlUp).Row ' 2 COLUMN B
For i = 1 To lRow
If ws.Cells(i, 2).Value = Me.NameForDateEntryBox.List(Me.NameForDateEntryBox.ListIndex) Then ' 2 IS COLUMN B
Rows(i).Select
Rows(i).Delete
Call populate
Application.ScreenUpdating = True
MsgBox "SUCESSFUL DELETION OF CUSTOMER " & NameForDateEntryBox.Value, vbInformation, "DELETE CONFIRMATION MESSAGE"
Exit For
End If
Next i
End If
End Sub