gheyman
Well-known Member
- Joined
- Nov 14, 2005
- Messages
- 2,347
- Office Version
- 365
- Platform
- Windows
When I run this code, its not completing the refresh of the table until after the part in the code that reformats the table. So basically when the table is finished refreshing, it removed the formatting
Is there a way to have this so that the formatting part doesn't happen until after the refreshing of the BoM table is done??
Sheets("BoM").ListObjects(1).QueryTable.Refresh
I thought the DoEvents would do what I needed.
Is there a way to have this so that the formatting part doesn't happen until after the refreshing of the BoM table is done??
Sheets("BoM").ListObjects(1).QueryTable.Refresh
I thought the DoEvents would do what I needed.
Code:
Private Sub CommandButton1_Click()
'*Run the Refresh on the Proposal_Tasks table to update it to the selected Proposal
UserFormSP.Hide
UserFormX.Show vbModeless
'Application.ScreenUpdating = False
'*************************************************************
UserFormX.LabelProg.Width = 65
UserFormX.LabelProg.Caption = "36%"
DoEvents
'*************************************************************
Sheets("Proposal Tasks").ListObjects(1).QueryTable.Refresh
'*************************************************************
UserFormX.LabelProg.Width = 152
UserFormX.LabelProg.Caption = "68%"
DoEvents
'*************************************************************
Sheets("Proposal Tasks").Select
'*************************************************************
UserFormX.LabelProg.Width = 176
UserFormX.LabelProg.Caption = "76%"
DoEvents
'*************************************************************
Sheets("BoM").ListObjects(1).QueryTable.Refresh
'*************************************************************
UserFormX.LabelProg.Width = 176
UserFormX.LabelProg.Caption = "82%"
DoEvents
'*************************************************************
'* Format the BoM - Adds a blank row in-between each Task/BoM to make it visually easier
Sheet4.Select
Dim col As String
Dim col2 As String
Dim i As Long
Dim startRow As Long
Dim lastRow As Long
col = "F"
col2 = "A"
startRow = 4
lastRow = Cells(Rows.Count, col).End(xlUp).Row
With ActiveSheet
For i = lastRow To startRow Step -1
If Range("F" & i).Value = "1" Then
.Cells(i, col).EntireRow.Insert shift:=xlDown
End If
If Range("A" & i).Value = "" Then
.Cells(i, col).EntireRow.RowHeight = 9
End If
Next i
End With
'*************************************************************
UserFormX.LabelProg.Width = 198
UserFormX.LabelProg.Caption = "99%"
DoEvents
'*************************************************************
UserFormX.Hide
MsgBox "On the BoM tab reviewed selected cost, modifiy selected cost or add new selected cost sources."
End Sub