Deleting a Range instead of a Row if Cell = X

NextWorldAngel

New Member
Joined
Oct 19, 2006
Messages
31
I'm using the below code, but I need to edit it where I can delete The cells of the row with XXXX in a specific column from column A:AW. I have some data in other columns that I need to not delete.

So basically if I2 = "XXXX" then delete A2:AW2 and shift up.



Sub Update3()

Dim Firstrow As Long
Dim Lastrow As Long
Dim Lrow As Long
Dim CalcMode As Long
Dim ViewMode As Long

With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With

With ActiveSheet

.Select

ViewMode = ActiveWindow.View
ActiveWindow.View = xlNormalView

.DisplayPageBreaks = False

Firstrow = .UsedRange.Cells(1).Row
Lastrow = .UsedRange.Rows(.UsedRange.Rows.Count).Row

For Lrow = Lastrow To Firstrow Step -1

With .Cells(Lrow, "I")

If Not IsError(.Value) Then

If Not IsError(Application.Match(.Value, _
Array("XXXX"), 0)) Then .Row.Delete

End If

End With

Next Lrow

End With

ActiveWindow.View = ViewMode
With Application
.ScreenUpdating = True
.Calculation = CalcMode
End With

End Sub

End Sub
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Perhaps:

Code:
If Not IsError(Application.Match(.Value, Array("XXXX"), 0)) Then Range("A" & .Row, "AW" & .Row).Delete xlShiftUp

Can you tell me the use of code like this:

Code:
With ActiveSheet

.Select

PS: Please post code on the forum here within
Code:
 tags - it makes the code readable at least. Thanks.
 
Upvote 0
Nope I get a compile error with that.

And no clue on the structure of the code. I know enough about VBA to do very basic macro editing and googling for what I am trying to do. This is an edited copy/paste that I found :)
 
Upvote 0

Forum statistics

Threads
1,224,583
Messages
6,179,683
Members
452,938
Latest member
babeneker

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