Color fill cells to be added into totals

G

Guest

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
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top