Macro to clear all rows with a "J" in them

tonywatsonhelp

Well-known Member
Joined
Feb 24, 2014
Messages
3,194
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
Hi everyone,
I need a macro that can go down column A an if an cells contain "J" clear the row?

seams easy but im having trouble please help

Thanks

Tony
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Is it only exactly "J" you are looking for in each cell, or can "J" be part of a longer entry, like "Joe"?
 
Upvote 0
How about
VBA Code:
Sub tonywatson()
   With Range("A1", Range("A" & Rows.Count).End(xlUp))
      .Replace "J", True, xlPart, , False, , False, False
      .SpecialCells(xlConstants, xlLogical).EntireRow.ClearContents
   End With
End Sub
 
Upvote 0
Yes, every cell is a formula that basicly looks at the row a decides if i need to keep it, if a do the answer is "" if i dont the answer is "J" (capital J if that matters?) so its any cell with just "J"
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0
As you have a formula returning the J, you could change the formula to return TRUE or "" & then just use
VBA Code:
      Range("A:A").SpecialCells(xlFormulas, xlLogical).EntireRow.ClearContents
 
Upvote 0

Forum statistics

Threads
1,215,444
Messages
6,124,891
Members
449,194
Latest member
JayEggleton

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