ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to? (https://www.excelbanter.com/excel-programming/308196-how.html)

Lee Hunter[_2_]

How to?
 
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.

Tod[_4_]

How to?
 
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
-----Original Message-----
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.
.


Lee HUnter

How to?
 
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.
-----Original Message-----
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
-----Original Message-----
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.
.

.


tod

How to?
 
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

-----Original Message-----
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.
-----Original Message-----
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
-----Original Message-----
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.
.

.

.



All times are GMT +1. The time now is 12:21 PM.

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