re : Help needed on some codes

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: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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top