Delete row on another sheet from a userform

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,832
Office Version
  1. 2007
Platform
  1. Windows
Hi,

I am on workssheet called DATABASE & currntly have a userform open.
Once the user has entered all the values in the fields he will use the command button to First delete the Active row on worksheet QUOTES then continue down through the code to apply userform values to worksheet called DATABASE.

I have clicked the command button expecting the active cell / row to be deleted & the rows below to move up then the userform values are sent to worksheet DATABASE.
I see a run timr error saying this process is not supported .

So i have typed something wrong BUT then not sure what code needs to follow after anyway ?





VBA Code:
Private Sub CommandButton1_Click()
   Dim answer As Integer
       answer = MsgBox("DELETE CUSTOMER ON QUOTES SHEET ? ", vbYesNo + vbCritical)
   If answer = vbYes Then
      ThisWorkbook.Sheets("QUOTES").ActiveCell.EntireRow.Delete xlUp
      MsgBox "CUSTOMER HAS NOW BEEN DELETED", vbInformation
      End If
 
  With ThisWorkbook.Worksheets("DATABASE")
 
    ThisWorkbook.Worksheets("DATABASE").Range("B6") = Me.ComboBox1.Text ' REGISTRATION NUMBER
    ThisWorkbook.Worksheets("DATABASE").Range("C6") = Me.ComboBox2.Text ' BLANK USED
    ThisWorkbook.Worksheets("DATABASE").Range("D6") = Me.ComboBox3.Text ' VEHICLE
    ThisWorkbook.Worksheets("DATABASE").Range("E6") = Me.ComboBox4.Text ' BUTTONS
    ThisWorkbook.Worksheets("DATABASE").Range("F6") = Me.ComboBox5.Text ' ITEM SUPPLIED
    ThisWorkbook.Worksheets("DATABASE").Range("G6") = Me.ComboBox6.Text ' TRANSPONDER CHIP
    ThisWorkbook.Worksheets("DATABASE").Range("H6") = Me.ComboBox7.Text ' JOB ACTION
    ThisWorkbook.Worksheets("DATABASE").Range("I6") = Me.ComboBox8.Text ' PROGRAMMER USED
    ThisWorkbook.Worksheets("DATABASE").Range("J6") = Me.ComboBox9.Text ' KEY CODE
    ThisWorkbook.Worksheets("DATABASE").Range("K6") = Me.ComboBox10.Text ' BITING
    ThisWorkbook.Worksheets("DATABASE").Range("L6") = Me.ComboBox11.Text ' CHASIS NUMBER
    ThisWorkbook.Worksheets("DATABASE").Range("N6") = Me.ComboBox12.Text ' VEHICLE YEAR
    ThisWorkbook.Worksheets("DATABASE").Range("R6") = Me.TextBox1.Text ' ADDRESS 1st LINE
    ThisWorkbook.Worksheets("DATABASE").Range("S6") = Me.TextBox2.Text ' ADDRESS 2nd LINE
    ThisWorkbook.Worksheets("DATABASE").Range("T6") = Me.TextBox3.Text ' ADDRESS 3rd LINE
    ThisWorkbook.Worksheets("DATABASE").Range("U6") = Me.TextBox4.Text ' ADDRESS 4TH LINE
    ThisWorkbook.Worksheets("DATABASE").Range("V6") = Me.TextBox5.Text ' POST CODE
    ThisWorkbook.Worksheets("DATABASE").Range("W6") = Me.TextBox6.Text ' CONTACT NUMBER
    ThisWorkbook.Worksheets("DATABASE").Range("O6") = Me.TextBox7.Text ' QUOTED / PAID
    ThisWorkbook.Worksheets("DATABASE").Range("L6") = Me.ComboBox11.Text ' CHASSIS NUMBER
    ThisWorkbook.Worksheets("DATABASE").Range("AA6") = Me.ComboBox13.Text ' SUPPLIER
    ThisWorkbook.Worksheets("DATABASE").Range("AC6") = Me.ComboBox14.Text ' PAYMENT TYPE
    ThisWorkbook.Worksheets("DATABASE").Range("AB6") = Me.ComboBox15.Text ' PART NUMBER
  
    End With
    Unload DatabaseToSheet2
End Sub
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
That new Textbox2 on the userform is where i put the code below.


VBA Code:
Private Sub TextBox2_Change()
    Dim Found As Range
       If Me.TextBox2.Value = "" Then
        MsgBox "NO VALUE TO LOOK FOR"
    Else
        Set Found = Sheets("QUOTES").Range("A:A").Find(What:=Me.TextBox2.Value, _
                                                       LookIn:=xlValues, _
                                                       LookAt:=xlWhole, _
                                                       SearchOrder:=xlByRows, _
                                                       SearchDirection:=xlNext, _
                                                       MatchCase:=False)
        If Found Is Nothing Then
            MsgBox "NOTHING WAS FOUND"
        Else
            Found.ThisWorkbook.Sheets("QUOTES").ActiveCell.EntireRow.Delete xlUp
        End If
    End If
End Sub
 
Upvote 0
The A12 sorry is the cell where the customers name is.
Its then that entire row that needs deleting
 

Attachments

  • EaseUS_2024_07_18_20_05_46.jpg
    EaseUS_2024_07_18_20_05_46.jpg
    40 KB · Views: 16
Upvote 0
Well I’m stumped so will await a reply.
Cant work out how to select that cell on the worksheet from the Textbox cell address value.
 
Upvote 0
Had you not ignored post 8
I suspect replacing .ActiveCell with .Range(Me.TextBox2) would have been suggested
 
Upvote 0
So you mean like this ?

VBA Code:
Dim answer As Integer
       answer = MsgBox("DELETE CUSTOMER ON QUOTES SHEET ? ", vbYesNo + vbCritical)
   If answer = vbYes Then
      ThisWorkbook.Sheets("QUOTES").Range(Me.TextBox2).EntireRow.Delete xlUp
      MsgBox "CUSTOMER HAS NOW BEEN DELETED", vbInformation
      End If
 
Upvote 0
Why do you need to select the cell?

I would think something like this would work

Excel Formula:
Sheets("Alpha").Range("A12").EntireRow.Delete
 
Upvote 0

Forum statistics

Threads
1,224,811
Messages
6,181,082
Members
453,021
Latest member
Justyna P

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