Refresh Data on hidden worksheet <--help please

D

Dan

Hello -

I have some VBA which will REFRESH DATA on a worksheet. However, when
the worksheet is hidden, the macro will not work.

How can I get this code to work on this HIDDEN WORKSHEET?

Sub JCW_Refresh()
Sheets("ODBC Updates").Select
Selection.QueryTable.Refresh BackgroundQuery:=False
Sheets("JCW").Select
End Sub

Thanks for helping out this rookie.
Dan
 
J

Jim Thomlinson

Try something more like this...

Sub JCW_Refresh()
application.screenupdating = false
with Sheets("ODBC Updates")
.visible = xlsheetvisible
.QueryTable.Refresh BackgroundQuery:=False
.visible = xlsheethidden
end with
application.screenupdating = true
End Sub
 
D

Dan

Try something more like this...

Sub JCW_Refresh()
application.screenupdating = false
with Sheets("ODBC Updates")
.visible = xlsheetvisible
.QueryTable.Refresh BackgroundQuery:=False
.visible = xlsheethidden
end with
application.screenupdating = true
End Sub
--
HTH...

Jim Thomlinson









- Show quoted text -

Thanks for the help. I tried this code but am still getting a DEBUG
error from this line:

..QueryTable.Refresh BackgroundQuery:=False

Regards,
Dan
 
J

Jim Thomlinson

Sorry... IIRC the sheet does not need to be visible. Try this (once again
untested but I think it should work)...

Sub JCW_Refresh()
Sheets("ODBC Updates").QueryTables(1).Refresh _
BackgroundQuery:=False
End Sub
 
D

Dan

Sorry... IIRC the sheet does not need to be visible. Try this (once again
untested but I think it should work)...

Sub JCW_Refresh()
Sheets("ODBC Updates").QueryTables(1).Refresh _
BackgroundQuery:=False
End Sub

--
HTH...

Jim Thomlinson








- Show quoted text -

Perfect! Thanks much for the assistance.

Dan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top