Worksheet Open First Time Only

Analyze This

Board Regular
Joined
Jul 25, 2003
Messages
133
Good Afternoon,

I would like to run a routine that renames my sheet names when a certain worksheet is opened / activated. The routine runs just fine, but how can I make it only run once per session? I need to wait until linked data is refreshed before I can rename my sheets, so I cannot add this to a workbook open statement. Any suggestions??

thank you!
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.

Oaktree

MrExcel MVP
Joined
Jun 20, 2002
Messages
8,016
Office Version
  1. 365
Is there a way to *tell* when you've refreshed your linked data (e.g. the linked data will pull in today's date or something)? If so, you should be able to include a line in your code to check that value and fire the rest of the code in your workbook_open event only if that value meets the desired criterion.
 

Analyze This

Board Regular
Joined
Jul 25, 2003
Messages
133
there would not be anything constant that happens, other than Excel automatically prompting the user to refresh links. I'm not sure how to tie that into the routine - awesome idea though!
 

Oaktree

MrExcel MVP
Joined
Jun 20, 2002
Messages
8,016
Office Version
  1. 365
Would changing the setting for updating links (edit --> links --> startup prompt) to "Don't display the alert and update links" circumvent your problem?
 

Analyze This

Board Regular
Joined
Jul 25, 2003
Messages
133
No - I have a routine in workbook.open that must run before the second routine. I don't know how to code for something to run after the prompted link refresh, do you?
 

Oaktree

MrExcel MVP
Joined
Jun 20, 2002
Messages
8,016
Office Version
  1. 365
No, but if you want to run something, update links, then run more code, consider using this:
Code:
ActiveWorkbook.UpdateLink Name:=ActiveWorkbook.LinkSources
in your code.

Try setting the startup prompt to "Don't display the alert and don't update links" and using that code instead of relying on the user's selection.
 

Forum statistics

Threads
1,144,698
Messages
5,725,822
Members
422,643
Latest member
elwayfan446

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
Top