Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
jer jer is offline
external usenet poster
 
Posts: 8
Default macros across multiple worksheets ...

I am not sure where to post this. It was already posted
in the worksheet functions group. I have a workbook with
multiple sheets, a master sheet and "supporting"
sheets all of which are formatted similiarly The
supporting are subsets of the master broken down by type
of transactions based on customer type. I have used the
following to get the results I want on the mastersheet
(all this is still relatively new to me), however when I
attempt to do this for the other sheets I am getting all
zeros. Is there a way to have this run on all sheets

The ranges to sum are dynamic and not a static size.

Dim nonin As Range, nonout As Range, nbkcell As Range
Set nbkcell = ActiveSheet.Cells(65536, 5).End
(xlUp).Offset(1, 0)
Set nonin = Intersect(Range("e:e"),
ActiveSheet.UsedRange)
Set nonout = nonin.Offset(0, 3)
nonin.Name = "nonin"
nonout.Name = "nonout"

nbkcell.Offset(2, 0).Value = "=SUM(nonin)"
nbkcell.Offset(2, 3).Value = "=SUM(nonout)"
nbkcell.Offset(2, -1).Value = "=COUNT(nonin)"
nbkcell.Offset(4, 0).Value = "=SUM(nonin,nonout)"

TIA for any help/suggestions
jer
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default macros across multiple worksheets ...

I'm not sure why you're getting all 0's, unless the last worksheet you run this
against has those formulas evaluate to 0.

When you use this line:
nonin.Name = "nonin"
This means that you've added a workbook level name called nonin. Each of your
formulas on the other sheets will use that last definition. Workbook level
names are global to the workbook.

If you create the name using the name of the sheet, you can reuse the same
"base" name as many times as you want:

Option Explicit
Sub testme()

Dim nonin As Range, nonout As Range, nbkcell As Range
Set nbkcell = ActiveSheet.Cells(65536, 5).End(xlUp).Offset(1, 0)
Set nonin = Intersect(Range("e:e"), ActiveSheet.UsedRange)
Set nonout = nonin.Offset(0, 3)
nonin.Name = "'" & ActiveSheet.Name & "'!nonin"
nonout.Name = "'" & ActiveSheet.Name & "'!nonout"

nbkcell.Offset(2, 0).Value = "=SUM(nonin)"
nbkcell.Offset(2, 3).Value = "=SUM(nonout)"
nbkcell.Offset(2, -1).Value = "=COUNT(nonin)"
nbkcell.Offset(4, 0).Value = "=SUM(nonin,nonout)"
End Sub

Since you're working with names, you may want to download a copy of Jan Karel
Pieterse's (with Charles Williams and Matthew Henson) Name Manager.

You can find it at:
NameManager.Zip from http://www.bmsltd.co.uk/mvp

(It really makes working with names easier.)

jer wrote:

I am not sure where to post this. It was already posted
in the worksheet functions group. I have a workbook with
multiple sheets, a master sheet and "supporting"
sheets all of which are formatted similiarly The
supporting are subsets of the master broken down by type
of transactions based on customer type. I have used the
following to get the results I want on the mastersheet
(all this is still relatively new to me), however when I
attempt to do this for the other sheets I am getting all
zeros. Is there a way to have this run on all sheets

The ranges to sum are dynamic and not a static size.

Dim nonin As Range, nonout As Range, nbkcell As Range
Set nbkcell = ActiveSheet.Cells(65536, 5).End
(xlUp).Offset(1, 0)
Set nonin = Intersect(Range("e:e"),
ActiveSheet.UsedRange)
Set nonout = nonin.Offset(0, 3)
nonin.Name = "nonin"
nonout.Name = "nonout"

nbkcell.Offset(2, 0).Value = "=SUM(nonin)"
nbkcell.Offset(2, 3).Value = "=SUM(nonout)"
nbkcell.Offset(2, -1).Value = "=COUNT(nonin)"
nbkcell.Offset(4, 0).Value = "=SUM(nonin,nonout)"

TIA for any help/suggestions
jer


--

Dave Peterson

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
Macros is several worksheets Lisa Excel Discussion (Misc queries) 3 September 23rd 08 07:34 PM
Macros with Protected Worksheets Terri Excel Discussion (Misc queries) 1 April 13th 06 06:27 PM
Macros and worksheets cinvic Excel Discussion (Misc queries) 2 March 14th 06 04:19 PM
macros affecting different worksheets CJW Excel Discussion (Misc queries) 1 September 2nd 05 04:29 PM
creating macros in multiple worksheets Shana@KL Excel Worksheet Functions 0 August 26th 05 04:49 AM


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

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"