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

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.

Forum statistics

Threads
1,223,883
Messages
6,175,167
Members
452,615
Latest member
bogeys2birdies

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