How to?

  • Thread starter Thread starter Lee Hunter
  • Start date Start date
L

Lee Hunter

I need to gather some counts from a worksheet and return
them to another sheet.

Workbook #1 Sheet 1 RC A3 is to hold the totals from
Workbook #2 Sheet 1 RC to be determined by inspection.
This calculation should occur when Workbook #1 is opened.

I have the code necessary to find and calculate the
totals in a worksheet_activate sub for Workbook #2 Sheet
#1, but can't get it to be triggered without manually
opening the sheet, then clicking in another sheet, then
back to the 1st sheet.

What events can be triggered by just opening Workbook #1?

Can you assist?
Thanks.
 
There is a workbook open event. You could do something
like this:

Private Sub Workbook_Open()
Dim wb As Workbook

'For each workbook that is currently open
For Each wb In Workbooks
'If workbook named "Workbook2.xls" is open
If wb.Name = "Workbook2.xls" Then
'Run your code and exit sub
'Put your code here or call a procedure
Exit Sub
End If
Next wb
'If Workbook2 is not open nothing happens

End Sub

tod
 
Thanks Tod.

Does the Workbook open event occur when any workbook is
opened? Can I open workbook 2 from the open event in
workbook 1 and activate the workbook 2 worksheet 1?
What would that code look like?

Thanks again.
 
Each workbook you open has its own Workbook Open event.
If you put code in the Open event of a particular
workbook, that code will run whenver that workbook is
opened, but not when other workbooks are opened. Let me
know if you have more questions.

tod
 

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

Back
Top