ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Color fill cells to be added into totals (https://www.excelbanter.com/excel-worksheet-functions/163286-color-fill-cells-added-into-totals.html)

hoolieo

Color fill cells to be added into totals
 
I want to color fill certain cells in a column and then have excel total the
colored cells of that column into a total cell. How do I do this? Alan

Carlo

Color fill cells to be added into totals
 
Hi Alan

I don't know how easy that will be with formulas (or if even possible)
I would say use VBA.

something like:

Sub ColorCellCalc()

Dim wantedColumn as byte
Dim Sh_ as worksheet
Dim Tot_ as Double

Set Sh_ = Worksheets("Sheet1")
wantedColumn = 2 'which would be B, change it if you need a different one

For i = 1 to Sh_.cells(65536,wantedColumn).end(xlup).row
if Sh_.cells(i,wantedColumn).interior.colorindex < xlnone then
Tot_ = Tot_ + Sh_.cells(i,wantedColumn)
end if

next i

Sh_.range("A1").value = Tot_

End Sub

hth

Carlo
"hoolieo" wrote:

I want to color fill certain cells in a column and then have excel total the
colored cells of that column into a total cell. How do I do this? Alan



All times are GMT +1. The time now is 02:42 AM.

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