concatenate cell of certain color

mshunt13

New Member
Joined
Mar 26, 2020
Messages
15
Office Version
  1. 365
Platform
  1. Windows
I have a cell range, G4:AK4, that I would like to concatenate only the cells that are a certain color. The value of the cells are number. I would also like to include a coma between each number.
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
When you say they are a certain color, do you mean the cell background or the color of the font?
What color?
 
Upvote 0
The cell background. Right now the color is a gray color but it can be changed to any color.
 
Upvote 0
OK, here's a UDF for you that will do that.
The first parameter is for a cell that holds the color you want to check for and the second is your number range.
Note that if you change a color, you will have to hit F9 to recalculate it.


VBA Code:
Function ConcatenateByColor(srcColor As Range, NumberRange As Range)
Application.Volatile
Dim clr As Long, c As Range, s As String
clr = srcColor.Interior.Color
For Each c In NumberRange
    If c.Interior.Color = clr And IsNumeric(c) And c <> "" Then s = s & c & ","
Next
If Len(s) Then ConcatenateByColor = Left(s, Len(s) - 1)
End Function


Book2
DEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAH
4735046596562112846241515262664
5
673,65,96,56,21,12,84,62,41,51,52,6,26,64,99,85
7
Sheet1
Cell Formulas
RangeFormula
D6D6=concatenatebycolor(D4,G4:AK4)
 
Upvote 0
thanks. This works well with manually colored filled cells. Is there a way to make it work with conditional formatting?
 
Upvote 0
use a formula to determine which cells to format
Yes, but what is the formula?

It is quite likely that the same formula, or at least the logic behind it, can be used to do your count, rather than actually looking for and counting the coloured cells.
 
Upvote 0
if cell = "A", "True", "False", the cell changes to blue if true.

Row 1 has numbers 1 through 31. Row 2, 3 and 4 compares data. If the data does not match in rows 2-4, then row 7 another indicates the discrepancy with an "A". If there is an "A" in row 7 we have row 1 (with numbers 1-31) conditionally formated to change colors. To the left of row 1, i am using the concatenate information provided in this thread however it will only work if I manually color fill the cells.
 
Upvote 0
if cell = "A", "True", "False"
That is not a Conditional Formatting formula and the rest of the explanation is confusing given that we are not familiar with your data.
Can you post some actual sample data with the actual Conditional Formatting formula with XL2BB so that we can see the data, the CF formula(s) and copy it for for testing?
 
Upvote 0

Forum statistics

Threads
1,214,987
Messages
6,122,618
Members
449,092
Latest member
amyap

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top