delete rows with certain text

daveyc18

Well-known Member
Joined
Feb 11, 2013
Messages
707
Office Version
  1. 365
  2. 2010
hi,

after formatting,

I have some rows that contain "page xx of xx" and I want those lines deleted. i tried the following code , but to no avail:

Dim count
For count = Range("A" & Rows.count).End(xlUp).Row To 1 Step -1
If Range("A" & count) = "page*" Then Rows(count).Delete
Next
 

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.
also sometimes column G has the text "rep," but beside in column GH it's blank, but i also want the macro to automatically fill in "rep" in column H if column G has "rep"
 
Upvote 0
hi,

after formatting,

I have some rows that contain "page xx of xx" and I want those lines deleted. i tried the following code , but to no avail:

Dim count
For count = Range("A" & Rows.count).End(xlUp).Row To 1 Step -1
If Range("A" & count) = "page*" Then Rows(count).Delete
Next

Change "=" to "Like" (w/o the quote marks).
 
Upvote 0
Change "=" to "Like" (w/o the quote marks).


thanks !it worked!

how about this one:

also sometimes column G's rows has the text "rep," but beside in column H it's blank, but i also want the macro to automatically fill in "rep" in column H if column G has "rep"
 
Upvote 0
thanks !it worked!

how about this one:

also sometimes column G's rows has the text "rep," but beside in column H it's blank, but i also want the macro to automatically fill in "rep" in column H if column G has "rep"
You are welcome.

In col G, is "rep" returned by a formula or is it a constant?
 
Upvote 0
it's a constant

Try this:
Code:
Sub RepToColH()
Dim c As Range
With Range("G:G")
    .Replace "rep", "#N/A"
    For Each c In .SpecialCells(xlCellTypeConstants, xlErrors)
        c.Resize(1, 2).Value = "rep"
    Next c
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,798
Messages
6,121,635
Members
449,043
Latest member
farhansadik

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