Clear Contents Rather Than Delete Row

GA81848

Board Regular
Joined
Apr 25, 2005
Messages
124
I've been using this code I found on this site for some time which has worked well. However, I do have one problem which despite many attempts I cannot resolve.

Currently, this code deletes the whole row if an 'X' is a cell in the appropriate column. Rather than do this I would prefer that it only clears the contents from the row between columns A:G

Could someone help in amending this?

Dim LastRow As Long
Sheets("Data").Select
LastRow = Range("I65536").End(xlUp).Row

Range("AF3").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=IF(RC[-23]="""",""X"","""")"
Selection.Copy
Range("AF3:AF" & LastRow).Select
ActiveSheet.Paste

If Range("I3") <> 0 Then



With Worksheets("Data")
For Each Word In Array("X")
For rw = LastRow To 1 Step -1
On Error Resume Next
.Range("AF" & rw).Find(Word, LookIn:=xlValues).EntireRow.Delete
Next rw
Next Word
End With

Else

End If
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.

Forum statistics

Threads
1,224,389
Messages
6,178,299
Members
452,839
Latest member
grdras

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