refresh macro for hidden data

rabarnes

New Member
Joined
Sep 7, 2006
Messages
26
Hi

I'm creating an order input form using excel / query. My database is in a hidden sheet and my order input sheet and order form (printout) are visible sheets. I have set the data to refresh every hour but should a user need to refresh the data immediately I have created a button for this. My code for refreshing the sheet is fine when the database sheet is visible, but it doesn't work when it's hidden.

(Sorry if this is very simple - I'm quite new to vb and I'm teaching myself as I go along but can't find the answer anywhere).

Can anyone give me an example of the correct code required?

Thanks

Rowan
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Replace "Sheet1" to your hidden sheet name

Code:
Application.ScreenUpdating = False
    Sheets("Sheet1").Visible = True
    ActiveWorkbook.RefreshAll
    Sheets("Sheet1").Select
    ActiveWindow.SelectedSheets.Visible = False
    Application.Selection = True
 
Upvote 0
thanks

Hi Mark

Thanks for that, it updated the sheet fine but then inputted the word "TRUE" into my first input box on my input sheet?!

To get round it I just added a "clear contents" instruction at the end of the code you provided to get rid of it.

Thanks

Rowan
 
Upvote 0
You are very welcome

One thing to bare in mind

If you have a Query (Via MS Query) which is set to update on opening the document, the refreshall VB function on workbook open can clash

I had this a few weeks back, Query set to refresh on open & remove on close, I stupidly set a workbook_open - refresh all, which counter acted the query refresh

Got around it by putting a wait in the routine, of 5 seconds, this allowed for the query to be refreshed, then refresh the entire workbook & all pivot tables

Happy to help
 
Upvote 0

Forum statistics

Threads
1,214,525
Messages
6,120,052
Members
448,940
Latest member
mdusw

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