Forum Discussion
Excel - need progress bar in excel during processing and some enhancement
- Jul 22, 2021
Hi TheTallman
UserName in table 'Parameters'
For C5 in your table you can use : Application.UserName (https://docs.microsoft.com/en-us/office/vba/api/excel.application.username)
As a note only: this is not a parameter but an information. Nowhere in your queries you use something else than the 1st row of table 'Parameters'
Progress bar with % completion on screen
No way to get that information. This would require an ETA - something PQ doesn't provide. And assuming it could compute an ETA for queries where the Source is "under its control" i.e. an Excel table in the current workbook, this would require the server to provide an ETA for queries that fold to i.e. OData, SQL Server and the like
As an alternative you could do the following that will display, on the left side of the status bar, +/- where you are in the process of refreshing your 3 queries:
Sub RefreshJsonQueries() With Application .ScreenUpdating = False Worksheets("Tables").Activate .StatusBar = "Refreshing query JsonTable..." With ActiveSheet.ListObjects("JsonTableConnection").QueryTable .Refresh BackgroundQuery:=False End With Worksheets("Attributes").Activate .StatusBar = "Refreshing query JsonAttributesConnection..." With ActiveSheet.ListObjects("JsonAttributesConnection").QueryTable .Refresh BackgroundQuery:=False End With Worksheets("SetTypes").Activate .StatusBar = "Refreshing query JsonSetTypesConnection..." With ActiveSheet.ListObjects("JsonSetTypesConnection").QueryTable .Refresh BackgroundQuery:=False End With Worksheets("Main").Activate .StatusBar = "" .ScreenUpdating = True End With End Sub
Or create a UserForm to display the 3 "messages" in the middle of the screen
Hi TheTallman
UserName in table 'Parameters'
For C5 in your table you can use : Application.UserName (https://docs.microsoft.com/en-us/office/vba/api/excel.application.username)
As a note only: this is not a parameter but an information. Nowhere in your queries you use something else than the 1st row of table 'Parameters'
Progress bar with % completion on screen
No way to get that information. This would require an ETA - something PQ doesn't provide. And assuming it could compute an ETA for queries where the Source is "under its control" i.e. an Excel table in the current workbook, this would require the server to provide an ETA for queries that fold to i.e. OData, SQL Server and the like
As an alternative you could do the following that will display, on the left side of the status bar, +/- where you are in the process of refreshing your 3 queries:
Sub RefreshJsonQueries()
With Application
.ScreenUpdating = False
Worksheets("Tables").Activate
.StatusBar = "Refreshing query JsonTable..."
With ActiveSheet.ListObjects("JsonTableConnection").QueryTable
.Refresh BackgroundQuery:=False
End With
Worksheets("Attributes").Activate
.StatusBar = "Refreshing query JsonAttributesConnection..."
With ActiveSheet.ListObjects("JsonAttributesConnection").QueryTable
.Refresh BackgroundQuery:=False
End With
Worksheets("SetTypes").Activate
.StatusBar = "Refreshing query JsonSetTypesConnection..."
With ActiveSheet.ListObjects("JsonSetTypesConnection").QueryTable
.Refresh BackgroundQuery:=False
End With
Worksheets("Main").Activate
.StatusBar = ""
.ScreenUpdating = True
End With
End Sub
Or create a UserForm to display the 3 "messages" in the middle of the screen