Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Sum of cells spanning several worksheets

I have a workbook that will have a varying number of
worksheets. The worksheet names will be "list (1)"
thru "list (xx)". Each worksheet has several cells that
that use "conditional sum" function to total quantities of
items based defined conditions.

I'd like to have a place on "list (1)" that will provide
total quantities that span all "lists", but I'm not sure
where to start.

I think I want to count the number of worksheets
named "list (*)", then, if "list (4)" exists, add the
value of the specific cell, if not, add zero. Am I on the
right track, or is there a better way? Can someone show
how to get started? Point me in the right direction and
I'll run with it.

THANKS!
Rich
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 280
Default Sum of cells spanning several worksheets

Option Explicit

Sub Main()
'puts a formula in sheet List(1), cell A1 that
'sums cells A2 for all sheetss named like "list(*)".
Dim wks As Worksheet, str As String
For Each wks In ThisWorkbook.Worksheets
If LCase(wks.Name) Like "pist(*)" Then
Let str = str & "'" & wks.Name & "'!A2 + "
End If
Next wks
If Len(str) 0 Then
Worksheets("List(1)").Range("A1").Formula = _
"=" & Left(str, Len(str) - Len(" + "))
End If
End Sub

--
Bob Kilmer
"Rich" wrote in message
...
I have a workbook that will have a varying number of
worksheets. The worksheet names will be "list (1)"
thru "list (xx)". Each worksheet has several cells that
that use "conditional sum" function to total quantities of
items based defined conditions.

I'd like to have a place on "list (1)" that will provide
total quantities that span all "lists", but I'm not sure
where to start.

I think I want to count the number of worksheets
named "list (*)", then, if "list (4)" exists, add the
value of the specific cell, if not, add zero. Am I on the
right track, or is there a better way? Can someone show
how to get started? Point me in the right direction and
I'll run with it.

THANKS!
Rich



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 280
Default Sum of cells spanning several worksheets

Correction: list, not pist! (How embarassing.)

Option Explicit

Sub Main()
'puts a formula in sheet List(1), cell A1 that
'sums cells A2 for all sheets named like "list(*)".
Dim wks As Worksheet, str As String
For Each wks In ThisWorkbook.Worksheets
If LCase(wks.Name) Like "list(*)" Then
Let str = str & "'" & wks.Name & "'!A2 + "
End If
Next wks
If Len(str) 0 Then
Worksheets("List(1)").Range("A1").Formula = _
"=" & Left(str, Len(str) - Len(" + "))
End If
End Sub

--
Bob Kilmer

"Rich" wrote in message
...
I have a workbook that will have a varying number of
worksheets. The worksheet names will be "list (1)"
thru "list (xx)". Each worksheet has several cells that
that use "conditional sum" function to total quantities of
items based defined conditions.

I'd like to have a place on "list (1)" that will provide
total quantities that span all "lists", but I'm not sure
where to start.

I think I want to count the number of worksheets
named "list (*)", then, if "list (4)" exists, add the
value of the specific cell, if not, add zero. Am I on the
right track, or is there a better way? Can someone show
how to get started? Point me in the right direction and
I'll run with it.

THANKS!
Rich



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 280
Default Sum of cells spanning several worksheets

Option Explicit

Sub Main()
'sums cells A2 for all sheetss named like "list(*)"
'puts the sum in sheet List(1), cell A1
Dim wks As Worksheet, total As String
total = 0
For Each wks In ThisWorkbook.Worksheets
If LCase(wks.Name) Like "list(*)" Then
Let total = total + wks.Range("A2").Value
End If
Next wks
Worksheets("List(1)").Range("A1").Value = total
End Sub

--
Bob Kilmer
"Rich" wrote in message
...
I have a workbook that will have a varying number of
worksheets. The worksheet names will be "list (1)"
thru "list (xx)". Each worksheet has several cells that
that use "conditional sum" function to total quantities of
items based defined conditions.

I'd like to have a place on "list (1)" that will provide
total quantities that span all "lists", but I'm not sure
where to start.

I think I want to count the number of worksheets
named "list (*)", then, if "list (4)" exists, add the
value of the specific cell, if not, add zero. Am I on the
right track, or is there a better way? Can someone show
how to get started? Point me in the right direction and
I'll run with it.

THANKS!
Rich



  #5   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Sum of cells spanning several worksheets

Thanks, Bob.

-----Original Message-----
Correction: list, not pist! (How embarassing.)

Option Explicit

Sub Main()
'puts a formula in sheet List(1), cell A1 that
'sums cells A2 for all sheets named like "list(*)".
Dim wks As Worksheet, str As String
For Each wks In ThisWorkbook.Worksheets
If LCase(wks.Name) Like "list(*)" Then
Let str = str & "'" & wks.Name & "'!A2 + "
End If
Next wks
If Len(str) 0 Then
Worksheets("List(1)").Range("A1").Formula = _
"=" & Left(str, Len(str) - Len(" + "))
End If
End Sub

--
Bob Kilmer


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
Excel cells spanning multiple printed pages Brian B[_2_] Excel Discussion (Misc queries) 2 January 9th 08 02:33 PM
Range Spanning worksheets RD Wirr Excel Worksheet Functions 5 November 28th 06 04:08 PM
Ranges spanning worksheets RD Wirr Excel Worksheet Functions 0 November 22nd 06 07:04 AM
Time calculation (in hh.mm) spanning more than one day dtencza Excel Discussion (Misc queries) 8 August 16th 05 09:49 PM
Entering data and spanning adjacent cells QuartetmanIA Excel Discussion (Misc queries) 8 July 11th 05 04:44 PM


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