savannah84
New Member
- Joined
- Nov 30, 2017
- Messages
- 2
Hi Mr. Excel, I am attempting to write 2 different function codes and am requesting help, please. If I could merge both of these functions that would be even better! I will list the coding below, however, I am wanting to have the sum of only the yellow background highlighted cell values be placed within the active column on the active sheet on a specific row number.
Function ReturnRowNumber(ActiveCell As ReturnRowNumber, RowNumber As ReturnRowNumber)
Dim LR As Long, LC As Long
LR = ActiveCell.End(xlDown).Row
LC = ActiveCell.End(xlToRight).Column
Range(ActiveCell, Cells(LR, LC)).Select
End Function
Function SumByColor(CellColor As Range, rRange As Range)
Dim cSum As Long
Dim ColIndex As Integer
ColIndex = CellColor.Interior.ColorIdex
For Each cl In rRange
If cl.Interior.ColorIndex = ColIndex Then
cSum = WorksheetFunction.Sum(cl, cSum)
End If
Next ReturnRowNumber
SumByColor = cSum
End Function
TYIA!
Function ReturnRowNumber(ActiveCell As ReturnRowNumber, RowNumber As ReturnRowNumber)
Dim LR As Long, LC As Long
LR = ActiveCell.End(xlDown).Row
LC = ActiveCell.End(xlToRight).Column
Range(ActiveCell, Cells(LR, LC)).Select
End Function
Function SumByColor(CellColor As Range, rRange As Range)
Dim cSum As Long
Dim ColIndex As Integer
ColIndex = CellColor.Interior.ColorIdex
For Each cl In rRange
If cl.Interior.ColorIndex = ColIndex Then
cSum = WorksheetFunction.Sum(cl, cSum)
End If
Next ReturnRowNumber
SumByColor = cSum
End Function
TYIA!