ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Adding cells with specific colors (https://www.excelbanter.com/excel-discussion-misc-queries/36634-adding-cells-specific-colors.html)

spanishjon

Adding cells with specific colors
 

*I have created a table full of numbers ranging several rows and columns
(eg A1:A10), I would like to add up in an adjacent cell all those
numbers that I have highlighted in yellow (i.e. whose cell I have
changed the background to yellow). Ideally, I would like to be able to
change which of these numbers is highlighted and the adjacent cell to
change its sum respectively.
I am an intermediate in Excel and beginner in VBA so please go slow :)
I would appreciate any ideas. Thank you!!* ;)


--
spanishjon
------------------------------------------------------------------------
spanishjon's Profile: http://www.excelforum.com/member.php...o&userid=25491
View this thread: http://www.excelforum.com/showthread...hreadid=389391


Earl Kiosterud

Jon,

Using color is great. But there just aren't tools to act on it. Take a look
at "Formatting as data" at http://smokeylake.com/excel/excel_truths.htm.
You might see it'll be a good idea to get away from using color directly.
--
Earl Kiosterud
www.smokeylake.com

"spanishjon" wrote
in message ...

*I have created a table full of numbers ranging several rows and columns
(eg A1:A10), I would like to add up in an adjacent cell all those
numbers that I have highlighted in yellow (i.e. whose cell I have
changed the background to yellow). Ideally, I would like to be able to
change which of these numbers is highlighted and the adjacent cell to
change its sum respectively.
I am an intermediate in Excel and beginner in VBA so please go slow :)
I would appreciate any ideas. Thank you!!* ;)


--
spanishjon
------------------------------------------------------------------------
spanishjon's Profile:
http://www.excelforum.com/member.php...o&userid=25491
View this thread: http://www.excelforum.com/showthread...hreadid=389391




L. Howard Kittle

Hi Jon,

Give this a try. Name your cells DataY and run this macro. It will sum the
value of the yellow cells and display the total in F1 and in a message box.
Note: The cells color cannot be the result of conditional formatting.

Sub SumColorCountYellow()
Dim Yellow6 As Integer
Dim Cell As Range

For Each Cell In Range("DataY")
If Cell.Interior.ColorIndex = 6 Then
Yellow6 = Yellow6 + Cell.Value
End If
Next

Range("F1").Value = "Yellow = " & Yellow6

MsgBox " Yellow adds to " & Yellow6, _
vbOKOnly, "CountColor"

Range("F1").Value = ""
End Sub

HTH
Regards,
Howard

"spanishjon" wrote
in message ...

*I have created a table full of numbers ranging several rows and columns
(eg A1:A10), I would like to add up in an adjacent cell all those
numbers that I have highlighted in yellow (i.e. whose cell I have
changed the background to yellow). Ideally, I would like to be able to
change which of these numbers is highlighted and the adjacent cell to
change its sum respectively.
I am an intermediate in Excel and beginner in VBA so please go slow :)
I would appreciate any ideas. Thank you!!* ;)


--
spanishjon
------------------------------------------------------------------------
spanishjon's Profile:
http://www.excelforum.com/member.php...o&userid=25491
View this thread: http://www.excelforum.com/showthread...hreadid=389391




spanishjon


Thank you for the macro Howard, it really helped me. Exactly what Iwas
looking for!


--
spanishjon
------------------------------------------------------------------------
spanishjon's Profile: http://www.excelforum.com/member.php...o&userid=25491
View this thread: http://www.excelforum.com/showthread...hreadid=389391



All times are GMT +1. The time now is 08:59 PM.

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