Hi,
Please help me how to handle this thing..
I have this code to know the start and end used cell address:
RStart = Sheet1.Range("c1").End(xlDown).Address
REnd = Sheet1.Range("c65536").End(xlUp).Address
Because I intend to used this in my sum formula. In my program, I cannot identify how many records it will retrieve thats why i used the RStart and REnd code.
This is the sumbycolor function I used when I searched here at the forum:
Function SumByColor(InRange As Range, WhatColorIndex As Integer, _
Optional OfText As Boolean = False) As Double
Dim OK As Boolean
Dim RStart As Range
Dim REnd As Range
Dim RAddress As Range
'I just tried this to substitute with the cell range
RStart = Sheet1.Range("c1").End(xlDown).Address
REnd = Sheet1.Range("c65536").End(xlUp).Address
RAddress = Range(RStart, REnd)
Application.Volatile True
For Each RAddress In InRange.Cells
If OfText = True Then
OK = (RAddress.Font.ColorIndex = WhatColorIndex)
Else
OK = (RAddress.Interior.ColorIndex = WhatColorIndex)
End If
If OK And IsNumeric(RAddress.Value) Then
SumByColor = SumByColor + RAddress.Value
End If
Next RAddress
End Function
Formula to put in my cell:
=sumbycolor(Raddress,37,false)
But when I tried to used this in my sum formula, it didn't work.
Please help me..
Please help me how to handle this thing..
I have this code to know the start and end used cell address:
RStart = Sheet1.Range("c1").End(xlDown).Address
REnd = Sheet1.Range("c65536").End(xlUp).Address
Because I intend to used this in my sum formula. In my program, I cannot identify how many records it will retrieve thats why i used the RStart and REnd code.
This is the sumbycolor function I used when I searched here at the forum:
Function SumByColor(InRange As Range, WhatColorIndex As Integer, _
Optional OfText As Boolean = False) As Double
Dim OK As Boolean
Dim RStart As Range
Dim REnd As Range
Dim RAddress As Range
'I just tried this to substitute with the cell range
RStart = Sheet1.Range("c1").End(xlDown).Address
REnd = Sheet1.Range("c65536").End(xlUp).Address
RAddress = Range(RStart, REnd)
Application.Volatile True
For Each RAddress In InRange.Cells
If OfText = True Then
OK = (RAddress.Font.ColorIndex = WhatColorIndex)
Else
OK = (RAddress.Interior.ColorIndex = WhatColorIndex)
End If
If OK And IsNumeric(RAddress.Value) Then
SumByColor = SumByColor + RAddress.Value
End If
Next RAddress
End Function
Formula to put in my cell:
=sumbycolor(Raddress,37,false)
But when I tried to used this in my sum formula, it didn't work.
Please help me..