Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 52
Default applying modules to mulitple worksheet

i have written a sub test_values in modules named Identifychages. I know that
by runing the module it will perform the sub on the excel worksheet that i am
opening. however, i wish to run this sub on mulitiple worksheets on the same
workbook.how can i do it?anyone can give me advice? i still very new to vba
coding in excel.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 132
Default applying modules to mulitple worksheet


Violet, you want to pass the worksheet(s) as a parameter into your sub.
Then you can call the sub from another routine and pass in the worksheets.
Here's an example:


public sub test_values_Master( )
dim wkb as workbook
dim wks as worksheet

set wkb = activeworkbook ' or set wkb equal to any workbook you want

for each wks in wkb.worksheets
call test_values( wks )
next wks
end sub


public sub test_values( wks as worksheet )
' perform operations on wks
end sub

Hope this helps - let me know if it wasn't what you were looking for.

Regards,
Bill


"violet" wrote:

i have written a sub test_values in modules named Identifychages. I know that
by runing the module it will perform the sub on the excel worksheet that i am
opening. however, i wish to run this sub on mulitiple worksheets on the same
workbook.how can i do it?anyone can give me advice? i still very new to vba
coding in excel.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 52
Default applying modules to mulitple worksheet

Bill,

The code you have for me is for all the worksheets in the workbook?what if i
wan only selected few?

"Bill Pfister" wrote:


Violet, you want to pass the worksheet(s) as a parameter into your sub.
Then you can call the sub from another routine and pass in the worksheets.
Here's an example:


public sub test_values_Master( )
dim wkb as workbook
dim wks as worksheet

set wkb = activeworkbook ' or set wkb equal to any workbook you want

for each wks in wkb.worksheets
call test_values( wks )
next wks
end sub


public sub test_values( wks as worksheet )
' perform operations on wks
end sub

Hope this helps - let me know if it wasn't what you were looking for.

Regards,
Bill


"violet" wrote:

i have written a sub test_values in modules named Identifychages. I know that
by runing the module it will perform the sub on the excel worksheet that i am
opening. however, i wish to run this sub on mulitiple worksheets on the same
workbook.how can i do it?anyone can give me advice? i still very new to vba
coding in excel.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default applying modules to mulitple worksheet

Public Sub test_values_Master()
Dim wkb As Workbook
Dim wks As Worksheet

Set wkb = ActiveWorkbook ' or set wkb equal to any workbook you want

For Each wks In wkb.Worksheets(Array("Sheet2", "Sheet3"))
Call test_values(wks)
Next wks
End Sub

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"violet" wrote in message
...
Bill,

The code you have for me is for all the worksheets in the workbook?what if

i
wan only selected few?

"Bill Pfister" wrote:


Violet, you want to pass the worksheet(s) as a parameter into your sub.
Then you can call the sub from another routine and pass in the

worksheets.
Here's an example:


public sub test_values_Master( )
dim wkb as workbook
dim wks as worksheet

set wkb = activeworkbook ' or set wkb equal to any workbook you want

for each wks in wkb.worksheets
call test_values( wks )
next wks
end sub


public sub test_values( wks as worksheet )
' perform operations on wks
end sub

Hope this helps - let me know if it wasn't what you were looking for.

Regards,
Bill


"violet" wrote:

i have written a sub test_values in modules named Identifychages. I

know that
by runing the module it will perform the sub on the excel worksheet

that i am
opening. however, i wish to run this sub on mulitiple worksheets on

the same
workbook.how can i do it?anyone can give me advice? i still very new

to vba
coding in excel.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 52
Default applying modules to mulitple worksheet

strange..it doesn't work...

"Bob Phillips" wrote:

Public Sub test_values_Master()
Dim wkb As Workbook
Dim wks As Worksheet

Set wkb = ActiveWorkbook ' or set wkb equal to any workbook you want

For Each wks In wkb.Worksheets(Array("Sheet2", "Sheet3"))
Call test_values(wks)
Next wks
End Sub

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"violet" wrote in message
...
Bill,

The code you have for me is for all the worksheets in the workbook?what if

i
wan only selected few?

"Bill Pfister" wrote:


Violet, you want to pass the worksheet(s) as a parameter into your sub.
Then you can call the sub from another routine and pass in the

worksheets.
Here's an example:


public sub test_values_Master( )
dim wkb as workbook
dim wks as worksheet

set wkb = activeworkbook ' or set wkb equal to any workbook you want

for each wks in wkb.worksheets
call test_values( wks )
next wks
end sub


public sub test_values( wks as worksheet )
' perform operations on wks
end sub

Hope this helps - let me know if it wasn't what you were looking for.

Regards,
Bill


"violet" wrote:

i have written a sub test_values in modules named Identifychages. I

know that
by runing the module it will perform the sub on the excel worksheet

that i am
opening. however, i wish to run this sub on mulitiple worksheets on

the same
workbook.how can i do it?anyone can give me advice? i still very new

to vba
coding in excel.






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default applying modules to mulitple worksheet

You have to change the values in the array to your sheet names

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"violet" wrote in message
...
strange..it doesn't work...

"Bob Phillips" wrote:

Public Sub test_values_Master()
Dim wkb As Workbook
Dim wks As Worksheet

Set wkb = ActiveWorkbook ' or set wkb equal to any workbook you want

For Each wks In wkb.Worksheets(Array("Sheet2", "Sheet3"))
Call test_values(wks)
Next wks
End Sub

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"violet" wrote in message
...
Bill,

The code you have for me is for all the worksheets in the

workbook?what if
i
wan only selected few?

"Bill Pfister" wrote:


Violet, you want to pass the worksheet(s) as a parameter into your

sub.
Then you can call the sub from another routine and pass in the

worksheets.
Here's an example:


public sub test_values_Master( )
dim wkb as workbook
dim wks as worksheet

set wkb = activeworkbook ' or set wkb equal to any workbook you

want

for each wks in wkb.worksheets
call test_values( wks )
next wks
end sub


public sub test_values( wks as worksheet )
' perform operations on wks
end sub

Hope this helps - let me know if it wasn't what you were looking

for.

Regards,
Bill


"violet" wrote:

i have written a sub test_values in modules named Identifychages.

I
know that
by runing the module it will perform the sub on the excel

worksheet
that i am
opening. however, i wish to run this sub on mulitiple worksheets

on
the same
workbook.how can i do it?anyone can give me advice? i still very

new
to vba
coding in excel.






  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 52
Default applying modules to mulitple worksheet

got another problem now...you c my code is for highlighting changes..now prob
is that when one of the sheet that i declare in the array is empty..the array
of worksheet seem like will not load as any sheet that is declare after the
blank sheet, the macro "changes" will not work on those sheets.

eg.

For Each wks In wkb.Worksheets(Array("Korea", "China", "Malaysia", "Brunei"))
call changes
next wks

if korea sheet has no data, "china" sheet and the rest will not execute
changes

"violet" wrote:

i have written a sub test_values in modules named Identifychages. I know that
by runing the module it will perform the sub on the excel worksheet that i am
opening. however, i wish to run this sub on mulitiple worksheets on the same
workbook.how can i do it?anyone can give me advice? i still very new to vba
coding in excel.

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default applying modules to mulitple worksheet

Can you show us the changes macro please Violet?

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"violet" wrote in message
...
got another problem now...you c my code is for highlighting changes..now

prob
is that when one of the sheet that i declare in the array is empty..the

array
of worksheet seem like will not load as any sheet that is declare after

the
blank sheet, the macro "changes" will not work on those sheets.

eg.

For Each wks In wkb.Worksheets(Array("Korea", "China", "Malaysia",

"Brunei"))
call changes
next wks

if korea sheet has no data, "china" sheet and the rest will not execute
changes

"violet" wrote:

i have written a sub test_values in modules named Identifychages. I know

that
by runing the module it will perform the sub on the excel worksheet that

i am
opening. however, i wish to run this sub on mulitiple worksheets on the

same
workbook.how can i do it?anyone can give me advice? i still very new to

vba
coding in excel.



  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 132
Default applying modules to mulitple worksheet

can you post the contents of the "changes" sub?


"violet" wrote:

got another problem now...you c my code is for highlighting changes..now prob
is that when one of the sheet that i declare in the array is empty..the array
of worksheet seem like will not load as any sheet that is declare after the
blank sheet, the macro "changes" will not work on those sheets.

eg.

For Each wks In wkb.Worksheets(Array("Korea", "China", "Malaysia", "Brunei"))
call changes
next wks

if korea sheet has no data, "china" sheet and the rest will not execute
changes

"violet" wrote:

i have written a sub test_values in modules named Identifychages. I know that
by runing the module it will perform the sub on the excel worksheet that i am
opening. however, i wish to run this sub on mulitiple worksheets on the same
workbook.how can i do it?anyone can give me advice? i still very new to vba
coding in excel.

Reply
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
Applying Formulas to a Range in a Worksheet Ra Excel Discussion (Misc queries) 4 June 15th 09 11:19 AM
Applying pop up calendar to entire worksheet Klee Excel Worksheet Functions 3 July 30th 07 07:28 AM
Alter Mulitple Protected VB Modules [email protected] Excel Programming 12 September 1st 06 12:06 PM
Can you have mulitple drop boxes on 1 worksheet? HEATHERCOX Excel Worksheet Functions 2 April 19th 05 11:45 PM
Worksheet Changes and applying code Nigel Bennett Excel Worksheet Functions 1 March 13th 05 06:49 PM


All times are GMT +1. The time now is 08:00 PM.

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

About Us

"It's about Microsoft Excel"