Add an IF Statement

pioshelby1980com

New Member
Joined
Jan 2, 2024
Messages
17
Office Version
  1. 365
Platform
  1. Windows
I have this code that I managed to cobble together to delete some rows:

Sub RemoveCEOrder()
Dim foundRange As Range

Set foundRange = Cells.Find(What:="CE Order", After:=ActiveCell, LookIn:= _
xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
xlNext, MatchCase:=False, SearchFormat:=False)

Rows(6).EntireRow.Delete
Rows(6).EntireRow.Delete
Rows(6).EntireRow.Delete
Rows(30).EntireRow.Delete
Rows(30).EntireRow.Delete
Rows(30).EntireRow.Delete
With Range("B29:P29").Borders(xlEdgeBottom)

.LineStyle = xlContinuous
.Color = RGB(68, 114, 196)
.Weight = xlThick
End With
End Sub

I would like to add a way to search for the string "CE Order" and if it exists then delete the rows but if it doesn't, then don't.

Can anyone help with this?
 
Guys,
Thanks for your help. I did as you suggested and it works except that it messes up one formula in a way that the AI bot didn't. Am I missing something?
Seeing as how you have not shown us any of the data or formulas on the sheet, I don't know how we are supposed to answer that.
 
Upvote 0

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying

Forum statistics

Threads
1,224,820
Messages
6,181,162
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