Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Problem # 1 : Delete Rows if Col "A" Cells < ("P1" OR "P2")
Delete Rows if Col "B" = "B" Row 1 Col A Col B Row 2 P1 A Row 3 P3 B Row 4 P1 A Row 5 P1 B Row 6 P2 B Row 7 P2 A Row 8 P3 A .. Expected result : Rows 2, 4, 7 would be kept My Code gives abnormal results. .. Problem # 2 : Abnormal processing Time over 8 minutes on 15,000 records. I suspect my code needs to be re-written. ----------------------------------- Sub DeleteRows() Dim strCheck As String Dim LRow As Long, i As Long Dim varData As Variant With Application .Calculation = xlCalculationManual .ScreenUpdating = False End With strCheck = "P1,P2" With Sheets("PM4") LRow = .Cells(Rows.Count, 1).End(xlUp).Row varData = .Range("A2:A" & LRow) For i = UBound(varData) To LBound(varData) Step -1 If InStr(strCheck, varData(i, 1)) = 0 Then Rows(i + 1).Delete End If Next End With With Sheets("PM4") LRow = .Cells(Rows.Count, 1).End(xlUp).Row varData = .Range("B2:B" & LRow) For i = UBound(varData) To LBound(varData) Step -1 With .Cells(i, "B") If Not IsError(.Value) Then If .Value = "B" Then .EntireRow.Delete End If End With Next End With With Application .Calculation = xlCalculationAutomatic .ScreenUpdating = True End With End Sub |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi J.P.,
Am Mon, 4 May 2015 11:10:47 -0700 (PDT) schrieb JeanPierre Charron: try: Sub DeleteRows() Dim strCheck As String Dim LRow As Long, i As Long Dim varData As Variant With Application .Calculation = xlCalculationManual .ScreenUpdating = False End With strCheck = "P1,P2" With Sheets("PM4") LRow = .Cells(Rows.Count, 1).End(xlUp).Row varData = .Range("A2:B" & LRow) For i = UBound(varData) To LBound(varData) Step -1 If InStr(strCheck, varData(i, 1)) = 0 Or varData(i, 2) = "B" Then Rows(i + 1).Delete End If Next End With With Application .Calculation = xlCalculationAutomatic .ScreenUpdating = True End With End Sub Regards Claus B. -- Vista Ultimate / Windows7 Office 2007 Ultimate / 2010 Professional |
#3
![]() |
|||
|
|||
![]()
xem truyện tranh nữ hoàng ai cập tập 20 Một học sinh đi chơi về tuyên bố với cả pḥng:
Cuối cùng rồi cũng có người con gái dám liều ḿnh v́ tao. Cả pḥng nhao nhao: - Ai vậy mày, nhỏ nào nói nghe coi? - Nhỏ Hồng bên lớp sử chứ ai! - Nhỏ nói ǵ với mày? - Nhỏ nói “Yêu ông ư? Tui thà nhảy lầu c̣n hơn”. Xem thêm đọc truyện tranh nư hoàng ai cập tập 4 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Deleting Rows on condition & Long processing time | Excel Programming | |||
Delete Rows with Conditions | Excel Programming | |||
Processing taking a really long time | Excel Discussion (Misc queries) | |||
Delete Rows for given conditions. | Excel Programming | |||
How to delete blank rows at one time in a long excel spreadsheet? | Excel Worksheet Functions |