Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 111
Default Running macros in newly created sheets

To All,

I have a macro that creates a series of new worksheets from a master
worksheet. I.e. it splits a set of data into different worksheets.

On each worksheet there is a list of numbers in Column C. I want to be
able to calculate the average of this list of numbers for all the new
worksheets that the first macro creates. I then want these values to be
pasted into a sheet called 'FINAL DATA' ( which already exists ) Is
this possible? and if so how?

Thanks for your help,

Regards

Joseph Crabtree

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Running macros in newly created sheets

Joseph,

Something like:

Sub AverageColumnC()
Dim mySh As Worksheet
For Each mySh In Worksheets
If mySh.Name < "FINAL DATA" Then
With Worksheets("Final Data").Range("A65536").End(xlUp)(2)
.Value = mySh.Name
.Offset(0, 1).Value = Application.Average(mySh.Range("C:C"))
End With
End If
Next mySh
End Sub

HTH,
Bernie
MS Excel MVP


"joecrabtree" wrote in message
ups.com...
To All,

I have a macro that creates a series of new worksheets from a master
worksheet. I.e. it splits a set of data into different worksheets.

On each worksheet there is a list of numbers in Column C. I want to be
able to calculate the average of this list of numbers for all the new
worksheets that the first macro creates. I then want these values to be
pasted into a sheet called 'FINAL DATA' ( which already exists ) Is
this possible? and if so how?

Thanks for your help,

Regards

Joseph Crabtree



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 111
Default Running macros in newly created sheets

Hello,

Thankyou very much for that. That works great. Just one further
question - If I want it to ignore more spreadsheets other than "FINAL
Data" how can I add this? For example if I want to ignore "Final Data
2" as well?

Thanks allot

Joseph

On Nov 28, 2:38 pm, "Bernie Deitrick" <deitbe @ consumer dot org
wrote:
Joseph,

Something like:

Sub AverageColumnC()
Dim mySh As Worksheet
For Each mySh In Worksheets
If mySh.Name < "FINAL DATA" Then
With Worksheets("Final Data").Range("A65536").End(xlUp)(2)
.Value = mySh.Name
.Offset(0, 1).Value = Application.Average(mySh.Range("C:C"))
End With
End If
Next mySh
End Sub

HTH,
Bernie
MS Excel MVP

"joecrabtree" wrote in oglegroups.com...



To All,


I have a macro that creates a series of new worksheets from a master
worksheet. I.e. it splits a set of data into different worksheets.


On each worksheet there is a list of numbers in Column C. I want to be
able to calculate the average of this list of numbers for all the new
worksheets that the first macro creates. I then want these values to be
pasted into a sheet called 'FINAL DATA' ( which already exists ) Is
this possible? and if so how?


Thanks for your help,


Regards


Joseph Crabtree- Hide quoted text -- Show quoted text -


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Running macros in newly created sheets

Joseph,

The best way depends on your naming convention. For example, you could use this to ignore all
sheets whose name starts with Final

If Left(mySh.Name,5) < "FINAL" Then

or you could use this to only process sheets with names that start with Data

If Left(mySh.Name,4) = "Data" Then

Since you control the new sheet addition, you can control the naming as well....

HTH,
Bernie
MS Excel MVP


"joecrabtree" wrote in message
ups.com...
Hello,

Thankyou very much for that. That works great. Just one further
question - If I want it to ignore more spreadsheets other than "FINAL
Data" how can I add this? For example if I want to ignore "Final Data
2" as well?

Thanks allot

Joseph

On Nov 28, 2:38 pm, "Bernie Deitrick" <deitbe @ consumer dot org
wrote:
Joseph,

Something like:

Sub AverageColumnC()
Dim mySh As Worksheet
For Each mySh In Worksheets
If mySh.Name < "FINAL DATA" Then
With Worksheets("Final Data").Range("A65536").End(xlUp)(2)
.Value = mySh.Name
.Offset(0, 1).Value = Application.Average(mySh.Range("C:C"))
End With
End If
Next mySh
End Sub

HTH,
Bernie
MS Excel MVP

"joecrabtree" wrote in
oglegroups.com...



To All,


I have a macro that creates a series of new worksheets from a master
worksheet. I.e. it splits a set of data into different worksheets.


On each worksheet there is a list of numbers in Column C. I want to be
able to calculate the average of this list of numbers for all the new
worksheets that the first macro creates. I then want these values to be
pasted into a sheet called 'FINAL DATA' ( which already exists ) Is
this possible? and if so how?


Thanks for your help,


Regards


Joseph Crabtree- Hide quoted text -- Show quoted text -




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
using a cell value to name a newly created workbook Guerilla Excel Discussion (Misc queries) 1 December 18th 06 01:45 AM
Can't find newly created userform Benz Excel Programming 1 July 13th 06 05:25 PM
in VBA Sheets("mysheet").Copy Befo=Sheets(1) how do i get a reference to the newly created copy of this sheet? Daniel Excel Worksheet Functions 1 July 6th 05 09:57 PM
Referencing a newly created worksheet Charyn Excel Worksheet Functions 2 May 2nd 05 04:13 AM
Add list to newly created menu Anthony Excel Discussion (Misc queries) 4 February 25th 05 01:53 AM


All times are GMT +1. The time now is 09:26 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"