ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   re : Help needed on some codes (https://www.excelbanter.com/excel-programming/366866-re-help-needed-some-codes.html)

dic09

re : Help needed on some codes
 

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


--
dic09
------------------------------------------------------------------------
dic09's Profile: http://www.excelforum.com/member.php...o&userid=36223
View this thread: http://www.excelforum.com/showthread...hreadid=560147



All times are GMT +1. The time now is 11:38 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com