ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   RefreshAll Data with VBA (https://www.excelbanter.com/excel-programming/289083-refreshall-data-vba.html)

JasonSelf[_4_]

RefreshAll Data with VBA
 
Well, this should be my last question for a little while. I need t
create a button that refreshes all data on a specific sheet (we wil
call it sheet1) I found this Worksheets(2).RefreshAll that is suppose
to do just that. I just don't understand exactly how I specify m
worksheet. The 2 is not the name of any of my sheets but doing
little searching I found that it may be the Index property....I do no
understand how I can determine the index property if that is indeed th
case.

Thanks for your help as always, any input would be greatl
appreciated.

Jason Sel

--
Message posted from http://www.ExcelForum.com


Tom Ogilvy

RefreshAll Data with VBA
 
I don't know where you found that code, but it raises an error for me. The
RefreshAll method is a method of the workbook, not the worksheet.

If it would work, you would use Worksheets("Sheet2").RefreshAll
to refer to a worksheet named Sheet2

If you have querytables on the sheet

Dim qt as QueryTable
for each qt in Worksheets("sheet2").QueryTables
qt.Refresh BackgroundQuery:=False
Next

for pivot Tables
Dim pt as PivotTable
for each pt in Worksheets("Sheet2").PivotTables
pt.RefreshTable
Next

Or if you just want to refresh the whole workbook

Workbooks("Myfile.xls").RefreshAll

--
Regards,
Tom Ogilvy


JasonSelf wrote in message
...
Well, this should be my last question for a little while. I need to
create a button that refreshes all data on a specific sheet (we will
call it sheet1) I found this Worksheets(2).RefreshAll that is supposed
to do just that. I just don't understand exactly how I specify my
worksheet. The 2 is not the name of any of my sheets but doing a
little searching I found that it may be the Index property....I do not
understand how I can determine the index property if that is indeed the
case.

Thanks for your help as always, any input would be greatly
appreciated.

Jason Self


---
Message posted from http://www.ExcelForum.com/




JasonSelf[_5_]

RefreshAll Data with VBA
 
I actually got that sippet of code from searching refreshall in the vb
help. Thanks for the help...doing that worked perfectly, Thanks

--
Message posted from http://www.ExcelForum.com



All times are GMT +1. The time now is 01:53 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com