ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Newbie: Dimming a variable. (https://www.excelbanter.com/excel-programming/392756-newbie-dimming-variable.html)

[email protected]

Newbie: Dimming a variable.
 
Got my hands on a function, and I'm having a bit of difficulty with
it.

Public 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

Compiler errors on "For Each Cell In", "Cell" comes up as an undefined
variable. So, I took out the "Option Explicit" at the top of the
module. FIXED THAT!!!! hahahahah.

Anyway, my question is: What should "Cell" be dimmed as?

Thanks so much for your help!

Aunt Joy


Chip Pearson

Newbie: Dimming a variable.
 
You should ALWAYS use Option Explicit. Dim your Cell variable As Range.


wrote in message
oups.com...
Got my hands on a function, and I'm having a bit of difficulty with
it.

Public 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

Compiler errors on "For Each Cell In", "Cell" comes up as an undefined
variable. So, I took out the "Option Explicit" at the top of the
module. FIXED THAT!!!! hahahahah.

Anyway, my question is: What should "Cell" be dimmed as?

Thanks so much for your help!

Aunt Joy



[email protected]

Newbie: Dimming a variable.
 

You should ALWAYS...


Yup, sorry you missed the sarcasm. Thanks for the ultra-quick
response.

Aunt Joy




All times are GMT +1. The time now is 04:40 PM.

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