Deleting rows when parameters are met in two columuns

Blanchetdb

Board Regular
Joined
Jul 31, 2018
Messages
164
Office Version
  1. 365
Platform
  1. Windows
I presently have a code that will delete all rows if the cell value in column C is matching from data (Me.TxtPRI.Vaue) in a UserForm

Private Sub Update()

lr = .Range("C" & Rows.Count).End(xlUp).Row

For I = lr To 1 Step -1
If .Cells(I, "C") = CDbl(Me.TxtPRI.Value) Then .Rows(I).Delete
Next I

End Sub

How can I add to this code so that rows will only delete if specific information entered in combobox (MeTxtPRI.Value) AND combobox (Me.ListCity.Value) is found in Column C and Column N?

example: the person inserts on the UserForm their PRI: 12345698 and the City is Halifax.......all rows that have that PRI and City are deleted

thank you
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
How about
Code:
Sub blanchetdb()
   With Sheets("Sheet1")
      If .AutoFilterMode Then .AutoFilterMode = False
      .Range("A1:N1").AutoFilter 3, CDbl(Me.TxtPRI.Value)
      .Range("A1:N1").AutoFilter 14, Me.ListCity.Value
      .AutoFilter.Range.Offset(1).EntireRow.Delete
      .AutoFilterMode = False
   End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,225,747
Messages
6,186,792
Members
453,371
Latest member
HMX180

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