LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default call code for all sheets

Through browsing this group, I have been able to apply code to all the
sheets in my workbook with the following test code.

Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Address < "$E$2" Then Exit Sub

Dim sh As Worksheet
For Each sh In ActiveWorkbook.Worksheets
sh.Activate
sh.Range("G2") = "test worked"
Next

End Sub
'--------------------------------------------------------------------------------------------

Is there any way to call a sub to all worksheets. I've tried
replaceing the SH.RANGE line with CALL TEST and it did not apply it to
all sheets. I've tried using WITH statements as follows:

Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Address < "$E$2" Then Exit Sub

Dim sh As Worksheet
For Each sh In ActiveWorkbook.Worksheets
sh.Activate
with sh
call test
end with
Next

End Sub

This did not work either. Any suggestions?

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Call a function in some sheets henpat Excel Programming 1 January 30th 06 01:23 PM
Can you call functions between sheets in the same book in excel? Arenlor Excel Worksheet Functions 3 January 7th 06 03:21 AM
VBA code: call subprocedure Terry Excel Programming 5 December 14th 05 04:49 AM
Code in one workbook to call code in another XL file [email protected] Excel Programming 2 August 1st 05 03:37 PM
call VBA compiled code within vba Les[_5_] Excel Programming 1 September 26th 03 06:27 PM


All times are GMT +1. The time now is 09:06 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"