I hv problem basically in updating my progress bar for comparing
sheets.
Sheets are compared between say "MYSHEET1" with "MYSHEET2" or "RULES1"
with "RULES2"
I need to update my progress bar for going through each row.
Assume my total columns are 30 and total rows are 541.
Below are my codes which compares sheets and mark invalid to
differences.
In box type comment code is my problem mark with # to update my
progress bar.
1-
Code:
--------------------
Sub CompareSheets_APFM()
Dim CmpSheets As New Collection
Dim i, sh, ce
Application.DisplayAlerts = False
Application.ScreenUpdating = False
For i = 1 To Sheets.count '<<<...determine comparison sheet names
On Error Resume Next
CmpSheets.Add Item:=Left(Sheets(i).Name, Len(Sheets(i).Name) - 1), _
Key:=Left(Sheets(i).Name, Len(Sheets(i).Name) - 1)
Next i
For Each sh In CmpSheets
With Sheets(sh & 1) 'Sheets of File-1
LastColumn1 = .UsedRange.Columns.count
LastRow1 = .UsedRange.Rows.count
End With
With Sheets(sh & 2) 'Sheets of File-2
LastColumn2 = .UsedRange.Columns.count
LastRow2 = .UsedRange.Rows.count
End With
If LastColumn1 > LastColumn2 Then '<< determine Ending comparison column
EndCol = LastColumn1
cmpCn = "" & GetXLColName(EndCol - 1) 'get column name (A-Z)
Else
EndCol = LastColumn2
cmpCn = "" & GetXLColName(EndCol - 1)
End If
If LastRow1 > LastRow2 Then '<< determine Ending comparison row
EndRow = LastRow1
Else
EndRow = LastRow2
End If
iCnt1 = EndRow * EndCol
iPro1 = 0
For Each ce In Range("A1:" & cmpCn & EndRow)
'################################################
'#If Not iPro1 = ce.Row Then: iPro1 = iPro1 + ce.Row 'problem is here
'################################################
cData1 = LTrim(Sheets(sh & 1).Range(ce.Address).Value)
cData2 = LTrim(Sheets(sh & 2).Range(ce.Address).Value)
If cData1 <> cData2 Then
'>> Mark Error
Sheets(sh & 1).Range(ce.Address).Interior.ColorIndex = 3
Sheets(sh & 1).Range(ce.Address).Font.ColorIndex = 2
Sheets(sh & 2).Range(ce.Address).Interior.ColorIndex = 3
Sheets(sh & 2).Range(ce.Address).Font.ColorIndex = 2
End If
Call SPKR.ProgressBar(Int(iPro1 * 100 / iCnt1))
Next ce
MsgBox "Finish- " & iPro1
Next sh
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
--------------------
2-
Code:
--------------------
Sub ProgressBar(ProgPercent As Integer) 'Update Progress Bar
With Me
.MeterBar1.Width = (.ProgBar1.Width / 100) * ProgPercent - 1
.ProgBar1.Caption = ProgPercent & "%"
If ProgPercent >= 50 Then .ProgBar1.ForeColor = 16777215
DoEvents
End With
End Sub
--------------------
Kindly help plzzz
also posted:
http://www.ozgrid.com/forum/showthread.php?t=41075