Formula based on cell formatting

Miguelluis

New Member
Joined
Jan 29, 2013
Messages
45
Hi,

I've got a sheet with data as follows

ClientName 1Name 2Name 3
1234PassportDLUtility
456PassportDL
Utility
778PassportDLUtility

<tbody>
</tbody>

I wanted to concatenate only if the cells or font is formatted with the colour red and list the items in separate lines, like below:

1234-Passport
-DL
-Utility
456-Passport
778-DL
-Utility

<tbody>
</tbody>

Assuming that the above correspond to the cells that were highlighted.

Is there a way of doing this?
Thanks
Miguel
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Not without VBA, I believe.
Native Excel functions run on values, not formatting.

However, I do not understand your example. I do not see anything highlighted in red, so I am afraid that your example isn't real clear.
 
Upvote 0
Not without VBA, I believe.
Native Excel functions run on values, not formatting.

However, I do not understand your example. I do not see anything highlighted in red, so I am afraid that your example isn't real clear.

Hi, Was having issues with highlighting.
ClientName 1Name 2Name 3
1234PassportDLUtility
456PassportDLUtility
778PassportDLUtility

<colgroup><col><col><col><col></colgroup><tbody>
</tbody>
 
Upvote 0
So, is VBA an acceptable solution for you?
Do you want this to happen in the same place, or on another sheet?
If in the same place, should the unhighlighted values simply be erased?
What if a line has a client, but no highlighted items? Do you want to show that Client code, or should that whole line be removed?
 
Upvote 0
VBA could work, I want it to pull the data to a separate sheet if highlighted only. Any cells that are not highlighted that client code/line doesn't pull through the new sheet.
 
Upvote 0
I think this code should do what you want. You may just need to change the two sheet names at the top of the code.
Code:
Sub MyCopyMacro()

    Dim srcSht As Worksheet
    Dim dstSht As Worksheet
    Dim lr As Long
    Dim r As Long
    Dim nr As Long
    Dim c As Long
    Dim client As String
    Dim nme As String
    Dim ct As Long
        
'   Set source and desination sheets
    Set srcSht = Sheets("Sheet1")
    Set dstSht = Sheets("Sheet2")
    
    Application.ScreenUpdating = False
    
'   Put headers in destination sheet
    dstSht.Range("A1") = "Client"
    dstSht.Range("B1") = "Name"
    
'   Find last row with data in column A on source sheet
    lr = srcSht.Cells(Rows.Count, "A").End(xlUp).Row
    
'   Loop through all rows from row 2 to end in source sheete
    For r = 2 To lr
        client = srcSht.Cells(r, "A")
'       Loop through columns 2-4
        ct = 0
        For c = 2 To 4
'           See if any fonts are red
            If srcSht.Cells(r, c).Font.Color = vbRed Then
                nme = srcSht.Cells(r, c)    'capture name
                nr = dstSht.Cells(Rows.Count, "B").End(xlUp).Row + 1    'capture new row
                ct = ct + 1     'capture count for this client
'               Populate client on destination sheet if first match for this client
                If ct = 1 Then dstSht.Cells(nr, "A") = client
'               Populate name on destination sheet
                dstSht.Cells(nr, "B") = nme
            End If
        Next c
    Next r
    
    Application.ScreenUpdating = True
                        
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,766
Messages
6,126,761
Members
449,336
Latest member
p17tootie

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