Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Laaibah Malik   on Nov 14 In MS Office Category.

  
Question Answered By: Bien Nguyen   on Nov 14

Thanks again for your help  and explanation.

I admit when I initially tried on my own not all the lines were being deleted.
This was prior to emailing the group.

Would it be possible to put expalnations against each line of code  from the
finished code below. It is a vey useful piece of code and I am sure other
members would also find it helpful.

Sorry for any inconvenience.

I am especially interested in these lines ...

If (I Mod (Round(Data_Rowcnt / 20, 0)) = 0) Then Application.StatusBar = I & "
of " & Data_Rowcnt & " = " & Round((I / Data_Rowcnt) * 100, 0) & "%"
AlertFlag = False


My final  code ...

Option Explicit
Sub Updates2()
Dim Data_Rowcnt, I, C, HideCnt, AlertFlag
HideCnt = 0
Application.ScreenUpdating = False
Data_Rowcnt = Application.WorksheetFunction.CountA(Range("A1: A65500"))
Cells.EntireRow.Hidden = False
Application.StatusBar = "Processing " & Data_Rowcnt & " Records"
For I = Data_Rowcnt To 1 Step -1
If (I Mod (Round(Data_Rowcnt / 20, 0)) = 0) Then Application.StatusBar =
I & " of " & Data_Rowcnt & " = " & Round((I / Data_Rowcnt) * 100, 0) & "%"
AlertFlag = False
For C = 1 To 26 'Look in columns  A to Z
If (UCase(Cells(I, C)) = "F") Then
Cells(I, C) = "Awaiting"
AlertFlag = True
End If
Next C
If (UCase(Cells(I, 12)) = "PASSPORT") And (Not AlertFlag) Or
(UCase(Cells(I, 13)) = "PASSPORT") And (Not AlertFlag) Then
HideCnt = HideCnt + 1
Rows(I).Delete Shift:=xlUp
End If

Next I
Cells.Select
Selection.Sort Key1:=Range("B2"), Order1:=xlAscending, _
Order2:=xlAscending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Range("A1").Select
Application.ScreenUpdating = True
Application.StatusBar = False
End Sub

Share: 

 

This Question has 21 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Hide / Show Rows based on Conditions Or get search suggestion and latest updates.


Tagged: