Problem with simple macro... Error 400

korcutt

New Member
Joined
Nov 14, 2005
Messages
3
Howdy All,
I'm trying to update/refreash the data in the worksheet by using the following code... If I "click" the "Cancel" button on the file dialog I get the wonderful error 400 with nothing else explained!

Here's the code:

Public Sub RefreshData()
Selection.QueryTable.Refresh
End Sub


Any ideas out there?????

Thanks in advance,

Kevin Orcutt
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
korcutt.

i guess i'm confused. what file dialog are you getting? i've got a web query and i used your code to update without trouble...and without dialog box.

thanks. ben.

ps. welcome to the board!!!
 
Upvote 0
Hello korcutt, welcome to the board!

You could always put an On Error Resume Next in your code above the offending line. Note that this is a fairly drastic measure as Excel will ignore all errors associated with your code. Generally, it's accepted practice to use some type of Error handler. If there is only one line, in this case, you don't really need something too elaborate.

If there are other actions you'd like to perform if there is an error, that can be done as well.

Is this what you are looking for?
 
Upvote 0

Forum statistics

Threads
1,215,019
Messages
6,122,707
Members
449,093
Latest member
Mnur

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