ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   function trouble (https://www.excelbanter.com/excel-programming/322572-function-trouble.html)

hans[_3_]

function trouble
 
I have this function:

Function hoogste(Optional maxweek As String) As String

Dim sh As Worksheet, sName As String
Dim maxindex As Long

maxweek = 0
maxindex = 0
For Each sh In ActiveWorkbook.Sheets
sName = sh.Name
If IsNumeric(sName) Then
If CLng(sName) < 53 Then
If CLng(sName) maxweek Then
'maxweek = CLng(sName)
maxweek = sName
maxindex = sh.Index
End If
End If
End If
Next
hoogste = "1:" & maxweek
End Function

It returns 1:12 if my highest sheetname is 12.

Now i want to sum cel c10 of all sheets 1 to 12

=SUM('1:12'!C6)
Every time my highest number is an other so i would like to use
=SUM('hoogste()'!C6)

this does not work, what am i doing wrong?

Greetings Hans

PS i use excel 2003



Tom Ogilvy

function trouble
 
The easiest way to do this is to add two additional blank sheets. Name one
Start and one Last
then change your formula to
=Sum(Start:Last!C6)

Place any sheets you want included in the sum between these two sheets (in
the tab order).

--
Regards,
Tom Ogilvy

"hans" wrote in message
...
I have this function:

Function hoogste(Optional maxweek As String) As String

Dim sh As Worksheet, sName As String
Dim maxindex As Long

maxweek = 0
maxindex = 0
For Each sh In ActiveWorkbook.Sheets
sName = sh.Name
If IsNumeric(sName) Then
If CLng(sName) < 53 Then
If CLng(sName) maxweek Then
'maxweek = CLng(sName)
maxweek = sName
maxindex = sh.Index
End If
End If
End If
Next
hoogste = "1:" & maxweek
End Function

It returns 1:12 if my highest sheetname is 12.

Now i want to sum cel c10 of all sheets 1 to 12

=SUM('1:12'!C6)
Every time my highest number is an other so i would like to use
=SUM('hoogste()'!C6)

this does not work, what am i doing wrong?

Greetings Hans

PS i use excel 2003






All times are GMT +1. The time now is 07:34 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com