SQUIDD
Well-known Member
- Joined
- Jan 2, 2009
- Messages
- 2,096
- Office Version
-
- 2019
- 2016
- Platform
-
- Windows
Hello everyone
I have a really long process that takes about 14 hours, i need to run this ? times.The problem is i have no idea how far it has got or how long it has left.I would like to disable screen refreshing and have a progress bar, only something simple to display the progress.
Thanks for help in advance.
Here is my code so far.
Dave
I have a really long process that takes about 14 hours, i need to run this ? times.The problem is i have no idea how far it has got or how long it has left.I would like to disable screen refreshing and have a progress bar, only something simple to display the progress.
Thanks for help in advance.
Here is my code so far.
Dave
Code:
Sub callmacro()
Dim r As Range
Dim n As Long
n = 1
Sheets("NUMBERS").Select
Set r = Range("A1")
While Not r.Value = ""
Call Macro1(r, n)
n = n + 1
Sheets("NUMBERS").Select
Set r = Range("A" & Trim(Str(n)))
Wend
End Sub
Sub Macro1(r As Range, i As Long)
'
' Macro1 Macro
' everything
'
'
Sheets("RACE IMPORT").Select
Range("A1").Select
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://www.thedogs.co.uk/resultsRace.aspx?raceID=" & r.Value, Destination _
:=Range("$A$1"))
.Name = "resultsRace.aspx?raceID=220401-11"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlOverwriteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = True
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
Sheets("TRAP 1").Select
Range("A1").Select
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://www.thedogs.co.uk/RaceCard.aspx?dogName=" & Range("24DOGS!$u$8").Value, Destination _
:=Range("$A$1"))
.Name = "RaceCard.aspx?dogName=Greylag Sam"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlOverwriteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
Range("b7:Z375").Select
ActiveWorkbook.Worksheets("TRAP 1").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("TRAP 1").Sort.SortFields.Add Key:=Range("Z9:Z156") _
, SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("TRAP 1").Sort
.SetRange Range("b7:Z375")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Sheets("TRAP 2").Select
Range("A1").Select
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://www.thedogs.co.uk/RaceCard.aspx?dogName=" & Range("24DOGS!$u$9").Value, Destination _
:=Range("$A$1"))
.Name = "RaceCard.aspx?dogName=Greylag Sam"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlOverwriteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
Range("b7:Z156").Select
ActiveWorkbook.Worksheets("TRAP 2").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("TRAP 2").Sort.SortFields.Add Key:=Range("Z9:Z156") _
, SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("TRAP 2").Sort
.SetRange Range("b7:Z156")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Sheets("TRAP 3").Select
Range("A1").Select
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://www.thedogs.co.uk/RaceCard.aspx?dogName=" & Range("24DOGS!$U$10").Value, Destination _
:=Range("$A$1"))
.Name = "RaceCard.aspx?dogName=Greylag Sam"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlOverwriteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
Range("b7:Z156").Select
ActiveWorkbook.Worksheets("TRAP 3").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("TRAP 3").Sort.SortFields.Add Key:=Range("Z9:Z156") _
, SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("TRAP 3").Sort
.SetRange Range("b7:Z156")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Sheets("TRAP 4").Select
Range("A1").Select
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://www.thedogs.co.uk/RaceCard.aspx?dogName=" & Range("24DOGS!$U$11").Value, Destination _
:=Range("$A$1"))
.Name = "RaceCard.aspx?dogName=Greylag Sam"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlOverwriteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
Range("b7:Z156").Select
ActiveWorkbook.Worksheets("TRAP 4").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("TRAP 4").Sort.SortFields.Add Key:=Range("Z9:Z156") _
, SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("TRAP 4").Sort
.SetRange Range("b7:Z156")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Sheets("TRAP 5").Select
Range("A1").Select
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://www.thedogs.co.uk/RaceCard.aspx?dogName=" & Range("24DOGS!$U$12").Value, Destination _
:=Range("$A$1"))
.Name = "RaceCard.aspx?dogName=Greylag Sam"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlOverwriteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
Range("b7:Z156").Select
ActiveWorkbook.Worksheets("TRAP 5").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("TRAP 5").Sort.SortFields.Add Key:=Range("Z9:Z156") _
, SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("TRAP 5").Sort
.SetRange Range("b7:Z156")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Sheets("TRAP 6").Select
Range("A1").Select
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://www.thedogs.co.uk/RaceCard.aspx?dogName=" & Range("24DOGS!$U$13").Value, Destination _
:=Range("$A$1"))
.Name = "RaceCard.aspx?dogName=Greylag Sam"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlOverwriteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
Range("b7:Z156").Select
ActiveWorkbook.Worksheets("TRAP 6").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("TRAP 6").Sort.SortFields.Add Key:=Range("Z9:Z156") _
, SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("TRAP 6").Sort
.SetRange Range("b7:Z156")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
Sheets("Print Form").Select
Range("A1:I39").Select
Selection.Copy
Sheets("data").Select
Range("A" & Trim(Str(40 * (i - 1) + 1))).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("TRAP 1").Select
Range("a1:v305").Select
Selection.ClearContents
Sheets("TRAP 2").Select
Range("a1:v305").Select
Selection.ClearContents
Sheets("TRAP 3").Select
Range("a1:v305").Select
Selection.ClearContents
Sheets("TRAP 4").Select
Range("a1:v305").Select
Selection.ClearContents
Sheets("TRAP 5").Select
Range("a1:v305").Select
Selection.ClearContents
Sheets("TRAP 6").Select
Range("a1:v305").Select
Selection.ClearContents
Sheets("RACE IMPORT").Select
Range("a1:u100").Select
Selection.ClearContents
End With
End Sub