refresh data vba question

  • Thread starter Thread starter JasonSelf
  • Start date Start date
J

JasonSelf

I have this code linked with a button on an excel sheet

Sub Refresh()
Workbooks("IDS Time Sheet.xls").RefreshAll
End Sub

The problem is that the end user will be copying this file and renamin
it so that "IDS Time SHeet.xls" would end up becoming another name lik
Username2-4-04.xls or something to that effect. Is there a way t
achieve the same thing no matter what the workbook name would end u
being?

Thanks as always
Jason Sel
 
Jason,

A worksheet has two names, the sheet name that we all know and love, and the
codename. When you look at the sheet objects in the VBE explorer window, you
will see something like 'Sheet1(Sheet1)'. This is the default status, when
the sheet name is changed in Excel, it will look like 'Sheet1(IDS Time
Sheet)'. You can also change the first, and your typical Excel user can't.

To change it, select the workbook in the VBE, and change the Name property
in the properties window.

To use it in VBA, use

Sub Refresh()
Sheet1.RefreshAll
End Sub
--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Thisworkbook.RefreshAll

thisworkbook is a reference to the workbook containing the code.
 
Bob,
The OP was a little confusing in his explanation, but RefreshAll is a method
of the workbook. I believe he meant there is a button on the sheet that
calls the macro.

--
Regards,
Tom Ogilvy

Bob Phillips said:
Jason,

A worksheet has two names, the sheet name that we all know and love, and the
codename. When you look at the sheet objects in the VBE explorer window, you
will see something like 'Sheet1(Sheet1)'. This is the default status, when
the sheet name is changed in Excel, it will look like 'Sheet1(IDS Time
Sheet)'. You can also change the first, and your typical Excel user can't.

To change it, select the workbook in the VBE, and change the Name property
in the properties window.

To use it in VBA, use

Sub Refresh()
Sheet1.RefreshAll
End Sub
--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
That answered my question perfectly. And the other things are good t
know as well (the codename stuff per sheet)

Thanks
Jason Sel
 
I answered a completely different question , but hopefully you can squirrel
it away for another day <vbg>

Bob
 
Back
Top