Hello,
I'm trying to add a few steps before the below "Rearrange Order" code is executed, namely, delete entire rows where column AG = 'D' and then delete entire rows where column O starts with a '3'. Can someone help me rewrite the code to delete entire rows given those two criteria and where do I enter it for it to execute on the "variable columns" tab -i.e. before the "Rearrange Order" macro runs and creates "New" tab?
My attempt at "delete row where column O starts with a '3'. This one doesn't work, my excel just kept spinning
I'm trying to add a few steps before the below "Rearrange Order" code is executed, namely, delete entire rows where column AG = 'D' and then delete entire rows where column O starts with a '3'. Can someone help me rewrite the code to delete entire rows given those two criteria and where do I enter it for it to execute on the "variable columns" tab -i.e. before the "Rearrange Order" macro runs and creates "New" tab?
VBA Code:
Sub Rearange_Order()
'
Sheets("variable colums").Select
I = Sheets("variable colums").Index
Sheets.Add
Sheets(I).Name = "New"
Last_Col_Fixed = Sheets("fixed columns").Range("IV1").End(xlToLeft).Column
Last_Col_Variable = Sheets("variable colums").Range("IV1").End(xlToLeft).Column
I_Col_New = 1
For I = 1 To Last_Col_Fixed
Search_Header = Sheets("fixed columns").Cells(1, I)
Sheets("variable colums").Select
Set C = Range(Cells(1, 1), Cells(1, Last_Col_Variable)).Find(Search_Header, LookIn:=xlValues)
If (Not (C) Is Nothing) Then
Cells(1, C.Column).EntireColumn.Copy Sheets("New").Cells(1, I_Col_New)
I_Col_New = I_Col_New + 1
End If
Next I
End Sub
My attempt at "delete row where column O starts with a '3'. This one doesn't work, my excel just kept spinning
VBA Code:
Sub Delete_Row()
On Error Resume Next
With Range("O1:O" & Range("3" & Rows.Count).End(xlUp).Row)
.Replace "3*", "#N/A", xlWhole
.SpecialCells(xlCellTypeConstants, xlErrors).EntireRow.Delete
End With
End Sub