Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 150
Default Sum Visible Cells

I have a column with the following formula in every row associated with data
(ie. Q5:Q32):

=IF(AND(B25<=L25,L25<480),"2","1")

In the "Totals" cell (Q33), I have the following formula:

{=SUM(VALUE(Q5:Q32))}

But, I need the "Totals" cell to only sum the visible cells when filtering.
I have tried the following VB function:

Function Sum_Visible_Cells(Cells_To_Sum As Object)
Application.Volatile
For Each cell In Cells_To_Sum
If cell.Rows.Hidden = False Then
If cell.Columns.Hidden = False Then
total = total + cell.Value
End If
End If
Next
Sum_Visible_Cells = total
End Function

But this does not work. Can anyone tell me how to fix this issue?
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 35,218
Default Sum Visible Cells

If you return real numbers in the first formula:
=IF(AND(B25<=L25,L25<480),2,1)

Then you could use
=subtotal(9,q5:q32)

And life would be easier--well, if you're not hiding columns. If you're hiding
columns, then this won't work.


Julie wrote:

I have a column with the following formula in every row associated with data
(ie. Q5:Q32):

=IF(AND(B25<=L25,L25<480),"2","1")

In the "Totals" cell (Q33), I have the following formula:

{=SUM(VALUE(Q5:Q32))}

But, I need the "Totals" cell to only sum the visible cells when filtering.
I have tried the following VB function:

Function Sum_Visible_Cells(Cells_To_Sum As Object)
Application.Volatile
For Each cell In Cells_To_Sum
If cell.Rows.Hidden = False Then
If cell.Columns.Hidden = False Then
total = total + cell.Value
End If
End If
Next
Sum_Visible_Cells = total
End Function

But this does not work. Can anyone tell me how to fix this issue?


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 150
Default Sum Visible Cells

The result of the first formula returns either number 2 or 1. How do I
ensure they are "real numbers"? All affected columns are unhidden but
"=subtotal(9,q5:q32)" still returns a value of 0 (zero)

"Dave Peterson" wrote:

If you return real numbers in the first formula:
=IF(AND(B25<=L25,L25<480),2,1)

Then you could use
=subtotal(9,q5:q32)

And life would be easier--well, if you're not hiding columns. If you're hiding
columns, then this won't work.


Julie wrote:

I have a column with the following formula in every row associated with data
(ie. Q5:Q32):

=IF(AND(B25<=L25,L25<480),"2","1")

In the "Totals" cell (Q33), I have the following formula:

{=SUM(VALUE(Q5:Q32))}

But, I need the "Totals" cell to only sum the visible cells when filtering.
I have tried the following VB function:

Function Sum_Visible_Cells(Cells_To_Sum As Object)
Application.Volatile
For Each cell In Cells_To_Sum
If cell.Rows.Hidden = False Then
If cell.Columns.Hidden = False Then
total = total + cell.Value
End If
End If
Next
Sum_Visible_Cells = total
End Function

But this does not work. Can anyone tell me how to fix this issue?


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 8,856
Default Sum Visible Cells

You are not returning number 2 or 1 - you are returning the text
values "2" or "1", so change your first formula to this:

=IF(AND(B25<=L25,L25<480),2,1)

as Dave had pointed out to you (i.e. get rid of the quotes around the
numbers).

Pete

On Feb 25, 10:05*pm, Julie wrote:
The result of the first formula returns either number 2 or 1. *How do I
ensure they are "real numbers"? *All affected columns are unhidden but
"=subtotal(9,q5:q32)" still returns a value of 0 (zero)



"Dave Peterson" wrote:
If you return real numbers in the first formula:
=IF(AND(B25<=L25,L25<480),2,1)


Then you could use
=subtotal(9,q5:q32)


And life would be easier--well, if you're not hiding columns. *If you're hiding
columns, then this won't work.


Julie wrote:


I have a column with the following formula in every row associated with data
(ie. Q5:Q32):


=IF(AND(B25<=L25,L25<480),"2","1")


In the "Totals" cell (Q33), I have the following formula:


{=SUM(VALUE(Q5:Q32))}


But, I need the "Totals" cell to only sum the visible cells when filtering.
I have tried the following VB function:


Function Sum_Visible_Cells(Cells_To_Sum As Object)
* * * *Application.Volatile
* * * *For Each cell In Cells_To_Sum
* * * * * *If cell.Rows.Hidden = False Then
* * * * * * * *If cell.Columns.Hidden = False Then
* * * * * * * * * *total = total + cell.Value
* * * * * * * *End If
* * * * * *End If
* * * *Next
* * * *Sum_Visible_Cells = total
* *End Function


But this does not work. *Can anyone tell me how to fix this issue?


--


Dave Peterson- Hide quoted text -


- Show quoted text -


  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 150
Default Sum Visible Cells

How could I be so silly to have missed that. Thank you both so much for your
help.
Greatly Appreciated.

"Pete_UK" wrote:

You are not returning number 2 or 1 - you are returning the text
values "2" or "1", so change your first formula to this:

=IF(AND(B25<=L25,L25<480),2,1)

as Dave had pointed out to you (i.e. get rid of the quotes around the
numbers).

Pete

On Feb 25, 10:05 pm, Julie wrote:
The result of the first formula returns either number 2 or 1. How do I
ensure they are "real numbers"? All affected columns are unhidden but
"=subtotal(9,q5:q32)" still returns a value of 0 (zero)



"Dave Peterson" wrote:
If you return real numbers in the first formula:
=IF(AND(B25<=L25,L25<480),2,1)


Then you could use
=subtotal(9,q5:q32)


And life would be easier--well, if you're not hiding columns. If you're hiding
columns, then this won't work.


Julie wrote:


I have a column with the following formula in every row associated with data
(ie. Q5:Q32):


=IF(AND(B25<=L25,L25<480),"2","1")


In the "Totals" cell (Q33), I have the following formula:


{=SUM(VALUE(Q5:Q32))}


But, I need the "Totals" cell to only sum the visible cells when filtering.
I have tried the following VB function:


Function Sum_Visible_Cells(Cells_To_Sum As Object)
Application.Volatile
For Each cell In Cells_To_Sum
If cell.Rows.Hidden = False Then
If cell.Columns.Hidden = False Then
total = total + cell.Value
End If
End If
Next
Sum_Visible_Cells = total
End Function


But this does not work. Can anyone tell me how to fix this issue?


--


Dave Peterson- Hide quoted text -


- Show quoted text -





  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 8,856
Default Sum Visible Cells

You're welcome, Julie - thanks for feeding back.

Pete

On Feb 25, 11:32*pm, Julie wrote:
How could I be so silly to have missed that. *Thank you both so much for your
help.
Greatly Appreciated.



"Pete_UK" wrote:
You are not returning number 2 or 1 - you are returning the text
values "2" or "1", so change your first formula to this:


=IF(AND(B25<=L25,L25<480),2,1)


as Dave had pointed out to you (i.e. get rid of the quotes around the
numbers).


Pete


On Feb 25, 10:05 pm, Julie wrote:
The result of the first formula returns either number 2 or 1. *How do I
ensure they are "real numbers"? *All affected columns are unhidden but
"=subtotal(9,q5:q32)" still returns a value of 0 (zero)


"Dave Peterson" wrote:
If you return real numbers in the first formula:
=IF(AND(B25<=L25,L25<480),2,1)


Then you could use
=subtotal(9,q5:q32)


And life would be easier--well, if you're not hiding columns. *If you're hiding
columns, then this won't work.


Julie wrote:


I have a column with the following formula in every row associated with data
(ie. Q5:Q32):


=IF(AND(B25<=L25,L25<480),"2","1")


In the "Totals" cell (Q33), I have the following formula:


{=SUM(VALUE(Q5:Q32))}


But, I need the "Totals" cell to only sum the visible cells when filtering.
I have tried the following VB function:


Function Sum_Visible_Cells(Cells_To_Sum As Object)
* * * *Application.Volatile
* * * *For Each cell In Cells_To_Sum
* * * * * *If cell.Rows.Hidden = False Then
* * * * * * * *If cell.Columns.Hidden = False Then
* * * * * * * * * *total = total + cell.Value
* * * * * * * *End If
* * * * * *End If
* * * *Next
* * * *Sum_Visible_Cells = total
* *End Function


But this does not work. *Can anyone tell me how to fix this issue?


--


Dave Peterson- Hide quoted text -


- Show quoted text -- 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
Sum of visible cells only Stgeorge Excel Worksheet Functions 11 August 23rd 06 04:58 PM
sum only visible cells hommer Excel Worksheet Functions 5 May 11th 06 11:39 PM
Visible Cells Only! Don Excel Worksheet Functions 2 May 2nd 05 09:48 PM
can i sum up only visible cells? Wink Excel Worksheet Functions 2 April 1st 05 07:10 PM
Visible cells Melissa Excel Worksheet Functions 0 February 15th 05 07:23 PM


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