ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How call procedure when worksheet opened? (https://www.excelbanter.com/excel-programming/351160-how-call-procedure-when-worksheet-opened.html)

John

How call procedure when worksheet opened?
 
The following macro call works fine when a specific cell is updated. How do I
call the macro when the worksheet is first opened?

Private Sub Worksheet_Activate(ByVal Target As Excel.Range)
If Target.Address = Range("hanwono").AddressLocal Then Call
PullExistingDataToHand
End Sub


Tom Ogilvy

How call procedure when worksheet opened?
 
In the ThisWorkbook module

Private Sub Workbook_Open()
' any conditions you might want
PullExistingDataToHand
End Sub

See Chip Pearson's page on Events
http://www.cpearson.com/excel/events.htm


--
Regards,
Tom Ogilvy

"John" wrote in message
...
The following macro call works fine when a specific cell is updated. How

do I
call the macro when the worksheet is first opened?

Private Sub Worksheet_Activate(ByVal Target As Excel.Range)
If Target.Address = Range("hanwono").AddressLocal Then Call
PullExistingDataToHand
End Sub




Bob Phillips[_6_]

How call procedure when worksheet opened?
 
Use the Workbook_Open event, not Activate

--

HTH

Bob Phillips

(remove nothere from the email address if mailing direct)

"John" wrote in message
...
The following macro call works fine when a specific cell is updated. How

do I
call the macro when the worksheet is first opened?

Private Sub Worksheet_Activate(ByVal Target As Excel.Range)
If Target.Address = Range("hanwono").AddressLocal Then Call
PullExistingDataToHand
End Sub




John

How call procedure when worksheet opened?
 
Tim, I'm pretty new at this VBA stuff, but I think this is almost all I need.
What condition to I check to be sure I'm on the "Hand" sheet to call this
procedure?

"Tom Ogilvy" wrote:

In the ThisWorkbook module

Private Sub Workbook_Open()
' any conditions you might want
PullExistingDataToHand
End Sub

See Chip Pearson's page on Events
http://www.cpearson.com/excel/events.htm


--
Regards,
Tom Ogilvy

"John" wrote in message
...
The following macro call works fine when a specific cell is updated. How

do I
call the macro when the worksheet is first opened?

Private Sub Worksheet_Activate(ByVal Target As Excel.Range)
If Target.Address = Range("hanwono").AddressLocal Then Call
PullExistingDataToHand
End Sub





Tom Ogilvy

How call procedure when worksheet opened?
 
Private Sub Workbook_Open()
If lcase(ThisWorkbook.Activesheet.Name) = "hand" then
PullExistingDataToHand
End if
End Sub

If you only want it to run when you open workbook and the default sheet is
named "Hand"

--
Regards,
Tom Ogilvy


"John" wrote in message
...
Tim, I'm pretty new at this VBA stuff, but I think this is almost all I

need.
What condition to I check to be sure I'm on the "Hand" sheet to call this
procedure?

"Tom Ogilvy" wrote:

In the ThisWorkbook module

Private Sub Workbook_Open()
' any conditions you might want
PullExistingDataToHand
End Sub

See Chip Pearson's page on Events
http://www.cpearson.com/excel/events.htm


--
Regards,
Tom Ogilvy

"John" wrote in message
...
The following macro call works fine when a specific cell is updated.

How
do I
call the macro when the worksheet is first opened?

Private Sub Worksheet_Activate(ByVal Target As Excel.Range)
If Target.Address = Range("hanwono").AddressLocal Then Call
PullExistingDataToHand
End Sub








All times are GMT +1. The time now is 07:48 PM.

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