D
dic09
Hi Experts,
Attached below is the code that I used to delete the rows that do not
have the cell values found in rng2
Dim Rngva As Range
Dim rCellva As Range
Dim delRngva As Range
Dim CalcModeva As Long
Set WB1 = Workbooks("DCR Template Daily")
Set SH1 = WB1.Sheets("Raw")
Set SH2 = WB1.Sheets("Selections")
Set rng1 = SH1.Columns("D")
Set rng2 = SH2.Range("C17")
With Application
CalcModeva = .Calculation
Calculation = xlCalculationAutomatic
ScreenUpdating = False
End With
For Each rCellva In rng1.Cells
If rCellva.Value <> rng2 Then
If delRngva Is Nothing Then
Set delRngva = rCellva
Else
Set delRngva = Union(rCellva, delRngva)
End If
End If
Next rCellva
If Not delRngva Is Nothing Then
delRngva.EntireRow.Delete
Else
'nothing found, do nothing
End If
With Application
Calculation = CalcModeva
ScreenUpdating = False
End With
My question is, if now i want to delete the rows that the cells values
are equal to rng2, how and where should be edited in the code???
AJ
Attached below is the code that I used to delete the rows that do not
have the cell values found in rng2
Dim Rngva As Range
Dim rCellva As Range
Dim delRngva As Range
Dim CalcModeva As Long
Set WB1 = Workbooks("DCR Template Daily")
Set SH1 = WB1.Sheets("Raw")
Set SH2 = WB1.Sheets("Selections")
Set rng1 = SH1.Columns("D")
Set rng2 = SH2.Range("C17")
With Application
CalcModeva = .Calculation
Calculation = xlCalculationAutomatic
ScreenUpdating = False
End With
For Each rCellva In rng1.Cells
If rCellva.Value <> rng2 Then
If delRngva Is Nothing Then
Set delRngva = rCellva
Else
Set delRngva = Union(rCellva, delRngva)
End If
End If
Next rCellva
If Not delRngva Is Nothing Then
delRngva.EntireRow.Delete
Else
'nothing found, do nothing
End If
With Application
Calculation = CalcModeva
ScreenUpdating = False
End With
My question is, if now i want to delete the rows that the cells values
are equal to rng2, how and where should be edited in the code???
AJ