How to fire the worksheet change event from workbook open event.

How to trigger workbook change event for a specific worksheet or all worksheet with workbook open event?

I have some code on a Private Sub Worksheet_Change(ByVal Target As Range)

this does not automatically fires up, unless something changes in the worksheet cell.

I want the worksheet change event to be fired when the workbook opens.
LVL 6
FloraAsked:
Who is Participating?
 
Skylar-BarlowCommented:
I had the same issue.  put this code into your workbook open event

change the sheet code name Sheet1  to the actual code name you have.

Run "Sheet1.worksheet_change", Range("a1")
0
 
ste5anSenior DeveloperCommented:
E.g.

On Local Error Resume Next

Dim Target As Excel.Range

Set Target = Nothing
Call Worksheet_Change(Target)

Open in new window


in the open event. But depending on the code in the change event, this may fail or even throw errors.
0
 
FloraAuthor Commented:
Did not work.

it threw error.

i copied your code and pasted in workbook open event. and it did not work.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
ste5anSenior DeveloperCommented:
Of course, you need to adjust it to your actual workbook...

Capture.PNG
btw, the correct approach would be having a public sub in a standard module, which is then called by both events.
1
 
NorieVBA ExpertCommented:
What does the code in the worksheet change event(s) do?

If also you want it to run when the workbook opens then perhaps it shouldn't be in the change event(s)?
0
 
FloraAuthor Commented:
0
 
FloraAuthor Commented:
Thank you ste5an
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.