G
gimley
Hi all experts!
I'm new to vba and after some sources and modifications, I came up wit
the code below:
****************
Sub KeepCellId()
Dim myRows As Long
Dim Start_Num As Integer
Dim End_Num As Integer
'Start_Num = "10000"
'End_Num = "19999"
Range("A1").EntireColumn.Insert
Range("A1").FormulaR1C1 = _
"=IF(ISNUMBER(RC[4]),IF(AND(RC[4]>=VALUE(""10000"")," & _
"RC[4]<=VALUE(""19999"")), ""Trash"",""Keep""),""Trash"")"
myRows = ActiveSheet.UsedRange.Rows.Count
Range("A1").Copy Range("A1:A" & myRows)
With Range(Range("A1"), Range("A1").End(xlDown))
.Copy
.PasteSpecial Paste:=xlValues
End With
Cells.Select
Selection.Sort Key1:=Range("A1"), Order1:=xlAscending
Columns("A:A").Find(What:="Trash", After:=Range("A1")).Select
Range(Selection, Selection.End(xlDown)).EntireRow.Delete
Range("A1").EntireColumn.Delete
End Sub
****************
I have 2 problems with this code:
1. I do not wish to edit the first row (row #1) as this row contain
the headings of each column.
2. I wish to delete all rows that contains numbers ranging fro
(10000-19999, 40000-49999 and 61452-69999) in column D. The whole rang
of numbers is from 10000-69999.
All help will be greatly appreciated!! Thanks in advance
I'm new to vba and after some sources and modifications, I came up wit
the code below:
****************
Sub KeepCellId()
Dim myRows As Long
Dim Start_Num As Integer
Dim End_Num As Integer
'Start_Num = "10000"
'End_Num = "19999"
Range("A1").EntireColumn.Insert
Range("A1").FormulaR1C1 = _
"=IF(ISNUMBER(RC[4]),IF(AND(RC[4]>=VALUE(""10000"")," & _
"RC[4]<=VALUE(""19999"")), ""Trash"",""Keep""),""Trash"")"
myRows = ActiveSheet.UsedRange.Rows.Count
Range("A1").Copy Range("A1:A" & myRows)
With Range(Range("A1"), Range("A1").End(xlDown))
.Copy
.PasteSpecial Paste:=xlValues
End With
Cells.Select
Selection.Sort Key1:=Range("A1"), Order1:=xlAscending
Columns("A:A").Find(What:="Trash", After:=Range("A1")).Select
Range(Selection, Selection.End(xlDown)).EntireRow.Delete
Range("A1").EntireColumn.Delete
End Sub
****************
I have 2 problems with this code:
1. I do not wish to edit the first row (row #1) as this row contain
the headings of each column.
2. I wish to delete all rows that contains numbers ranging fro
(10000-19999, 40000-49999 and 61452-69999) in column D. The whole rang
of numbers is from 10000-69999.
All help will be greatly appreciated!! Thanks in advance