R
ryguy7272
I downloaded a sample of a very cool Progress Bar from this site:
http://www.enhanceddatasystems.com/ED/Pages/ExcelProgressBar.htm
I am trying to determine how to implement it with my code, but can’t seem to
figure it out. How does the Progress Bar figure out how long the entire
process will take? Can someone please take a look at this, and let me know
what I am doing wrong?
For my code to run, just enter consecutive numbers 1 to 82, in AA1:AA82,
then run the macro:
Sub ProgBarDemo()
Dim PB As clsProgBar
Dim nCounter As Integer
Dim lWaitCount As Long
Set PB = New clsProgBar
With PB
.Title = "Enhanced Datasystems Progress Bar"
.Show
For nCounter = 0 To 100
.Progress = nCounter
.Caption1 = "Progress message " & CStr(nCounter)
For lWaitCount = 0 To 1000000
‘My macro begins here:
Application.DisplayAlerts = False
Columns("A:Z").Select
Range("Z1").Activate
Selection.ClearContents
Application.DisplayAlerts = True
Range("A1").Activate
For Each c In Sheets("Import Sheet").Range("AA1:AA82")
lstRw = Cells(Rows.Count, 1).End(xlUp).Row
str1 = "URL;http://www.osha.gov/pls/imis/sic_manual.display?id=" &
c.Value & "&tab=group"
With ActiveSheet.QueryTables.Add(Connection:=str1 _
, Destination:=Range("A" & lstRw + 1))
'.Name = str1
.Name = "sic_manual.display?id=" & c.Value & "&tab=group"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingNone
.WebTables = "5"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
Next c
Columns("A:B").Select
Range("B1").Activate
Selection.Copy
Range("Y1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Selection.Sort Key1:=Range("Z1"), Order1:=xlDescending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Columns("A:B").Select
Selection.ClearContents
Range("X1").Select
ActiveCell.FormulaR1C1 = "=RIGHT(RC[2],LEN(RC[2])-5)"
Range("X1").Select
Selection.AutoFill Destination:=Range("X1:X1004")
Range("X1:X1004").Select
Selection.Copy
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Selection.Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Range("A1").Select
If UserCancelled = True Then GoTo EndRoutine
Next lWaitCount
Next nCounter
EndRoutine:
.Finish
End With
Set PB = Nothing
End Sub
Cordially,
Ryan--
http://www.enhanceddatasystems.com/ED/Pages/ExcelProgressBar.htm
I am trying to determine how to implement it with my code, but can’t seem to
figure it out. How does the Progress Bar figure out how long the entire
process will take? Can someone please take a look at this, and let me know
what I am doing wrong?
For my code to run, just enter consecutive numbers 1 to 82, in AA1:AA82,
then run the macro:
Sub ProgBarDemo()
Dim PB As clsProgBar
Dim nCounter As Integer
Dim lWaitCount As Long
Set PB = New clsProgBar
With PB
.Title = "Enhanced Datasystems Progress Bar"
.Show
For nCounter = 0 To 100
.Progress = nCounter
.Caption1 = "Progress message " & CStr(nCounter)
For lWaitCount = 0 To 1000000
‘My macro begins here:
Application.DisplayAlerts = False
Columns("A:Z").Select
Range("Z1").Activate
Selection.ClearContents
Application.DisplayAlerts = True
Range("A1").Activate
For Each c In Sheets("Import Sheet").Range("AA1:AA82")
lstRw = Cells(Rows.Count, 1).End(xlUp).Row
str1 = "URL;http://www.osha.gov/pls/imis/sic_manual.display?id=" &
c.Value & "&tab=group"
With ActiveSheet.QueryTables.Add(Connection:=str1 _
, Destination:=Range("A" & lstRw + 1))
'.Name = str1
.Name = "sic_manual.display?id=" & c.Value & "&tab=group"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingNone
.WebTables = "5"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
Next c
Columns("A:B").Select
Range("B1").Activate
Selection.Copy
Range("Y1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Selection.Sort Key1:=Range("Z1"), Order1:=xlDescending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Columns("A:B").Select
Selection.ClearContents
Range("X1").Select
ActiveCell.FormulaR1C1 = "=RIGHT(RC[2],LEN(RC[2])-5)"
Range("X1").Select
Selection.AutoFill Destination:=Range("X1:X1004")
Range("X1:X1004").Select
Selection.Copy
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Selection.Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Range("A1").Select
If UserCancelled = True Then GoTo EndRoutine
Next lWaitCount
Next nCounter
EndRoutine:
.Finish
End With
Set PB = Nothing
End Sub
Cordially,
Ryan--