Code error when it gets to Refreshing a table(s)

gheyman

Well-known Member
Joined
Nov 14, 2005
Messages
2,347
Office Version
  1. 365
Platform
  1. Windows
I have code that does a bunch of things, but when it gets to the point where I am telling it to refresh these two tables. I am getting an error message. But if I break out these two lines into there own macro, they run fine (they refresh the tables without any errors) any suggestions

Run-Time error '1004':
Microsoft Excel is refreshing some data. Please try again later.

Sheets("Proposal Tasks").ListObjects(1).QueryTable.Refresh BackgroundQuery:=False
Sheets("Spread_Esc").ListObjects(1).QueryTable.Refresh BackgroundQuery:=False

Code:
Sub Import_PP_Report()

Sheets("CMCS_PBoM").Visible = True
'Sheets("Cost Summary").Visible = True
'Sheets("Validity Summary").Visible = True
'Sheets("Cost Drivers").Visible = True
'Sheets("Part Summary").Visible = True
'Sheets("Vendor Summary").Visible = True
'Sheets("VendorPart Summary").Visible = True

RemoveTab

UserFormX.Show vbModeless

Application.ScreenUpdating = False

'**************************************************
            UserFormX.LabelProg.Width = 48
            UserFormX.LabelProg.Caption = "28%"
            DoEvents
'**************************************************


GetCMCS

'**************************************************
            UserFormX.LabelProg.Width = 101
            UserFormX.LabelProg.Caption = "52%"
            DoEvents
'**************************************************


MakeTable

'AddTitleFormulas

'**************************************************
            UserFormX.LabelProg.Width = 150
            UserFormX.LabelProg.Caption = "76%"
            DoEvents
'**************************************************

Refresh_All_tables

'**************************************************
            UserFormX.LabelProg.Width = 196
            UserFormX.LabelProg.Caption = "99%"
            DoEvents
'**************************************************
CopyPropNameToTaskList
GetProposalIDfromMtrlAdHoc

'************This is where the error happens
'Refresh table ModelPropricer_vdataNISTaskView
Sheets("Proposal Tasks").ListObjects(1).QueryTable.Refresh BackgroundQuery:=False
Sheets("Spread_Esc").ListObjects(1).QueryTable.Refresh BackgroundQuery:=False

UserFormX.Hide

Sheets("CMCS_PBoM").Select

MsgBox "The CMCS_PBoM report is built off the ProPricer Export: Material Ad Hoc."

End Sub
[Code/]

as stated the code to refresh the tables when in its own macro runs fine.  It doesn't error out, but I wanted it to be done in all one step for the user.
any help is appreciated
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)

Forum statistics

Threads
1,223,892
Messages
6,175,236
Members
452,621
Latest member
Laura_PinksBTHFT

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top