+ Reply to Thread
Results 1 to 8 of 8

Concatenate Values | Retain Conditional Formatting of the Source

Hybrid View

  1. #1
    Registered User
    Join Date
    10-04-2013
    Location
    Manila, Philippines
    MS-Off Ver
    Excel 2010
    Posts
    19

    Concatenate Values | Retain Conditional Formatting of the Source

    Hello Everyone,

    I know this may sound like the other questions already answered in this forum. However, I didn't know how to customize answers already given here to work on my scenario.

    I have a range of data (7 columns by 12+ rows) that I need to combine in to one cell separated by a "/".

    Example:

    A2: Name
    A3: Data 1 - value obtained using a formula.
    A4: Data 2 - value obtained using a formula.
    A5: Data 3 - value obtained using a formula.
    A6: Data 4 - value obtained using a formula.
    A7: Data 5 - value obtained using a formula.

    A1: Result!

    Repeated on 12+ rows.

    I need the result to be like Name:<space>Data 1/Data 2/Data 3/Data 4/Data 5 and to retain the font color (red) set by conditional formatting.

    The other thing is, Data 2 & Data 5 needs to be in 00.00% format. I was able to obtain what I wanted using a formula (CONCATENATE). However, I need to manually set the color based on the conditional formatting.

    I hope you could help me figure this out.
    JCANLAS

  2. #2
    Registered User
    Join Date
    10-04-2013
    Location
    Irving, Texas
    MS-Off Ver
    Office 2003-07-10-13
    Posts
    34

    Re: Concatenate Values | Retain Conditional Formatting of the Source

    I'm confused by the conditional formatting piece?

    Which of the cells has conditional formatting?
    If all the cells, then do they all have the same criteria?
    If so, and the various criteria produce different resulting formats (based on the different values shown in each cell), what is the order of priorty for the applied formats to A1?

    Also, what is an example of what the existing value(s) would be for the two percentage formatted entries in the concatenated string?
    Correction/clarification: what is an example of the EXISTING values in data2 and data5 and do the values already represent percentages in need of the symbol, or would they need tobe multiplied by 100 and then have the symbol attached?
    For example:
    Data2 has a value of .1234, would normally format to a percentage of 12.34%
    or, is .1234 already in a percent and need to be rounded to 0.12%
    Last edited by Bilbo_Baggins; 10-04-2013 at 10:14 PM.

  3. #3
    Registered User
    Join Date
    10-04-2013
    Location
    Manila, Philippines
    MS-Off Ver
    Excel 2010
    Posts
    19

    Re: Concatenate Values | Retain Conditional Formatting of the Source

    Hi Bilbo_Baggins,

    Sorry, attached is the actual file.

    Book1.xlsx

  4. #4
    Registered User
    Join Date
    10-04-2013
    Location
    Manila, Philippines
    MS-Off Ver
    Excel 2010
    Posts
    19

    Re: Concatenate Values | Retain Conditional Formatting of the Source

    Hi Bilbo_Baggins,

    Each of the columns (Data 1 - Data 5) has a different criteria.

    The cell, I believe in Data 2 & 4 column, is already in 00.00% format. When I tried CONCATENATE, I believe I still multiply it by 100, (can't remember if I used ROUND to obtain the .00 part) and manually added &"%"& part.

    Correction: The parts in % format should be Data 2 & Data 4 columns.

  5. #5
    Registered User
    Join Date
    10-04-2013
    Location
    Irving, Texas
    MS-Off Ver
    Office 2003-07-10-13
    Posts
    34

    Re: Concatenate Values | Retain Conditional Formatting of the Source

    So, I've been working on this today.

    I was very easily able to build custom concatenate function that automatically brings all the values together with the proper percentage calculations and various delimiters (";" and "/") between the fields.
    It was a piece of cake.

    However, as I tried to then add in the formatting of the colors, within the same custom function, this proved to be impossible (unless somebody more skilled than I can tackle it).
    The problem here is not calculating the applicability of custom formats, or keeping track of the applicable formats. This too is actually very easy.
    What is impossible is to apply the formats to the characters before the end of the custom function.
    It turns out (as I suspected it would) two things are actually applicable here:
    1. Using a custom function places a function in the cell, not the value. Therefore, the representation of the concatenated result is just that, a representation.
    2. Even if you could magically tell a function to replace itself with its text result, that text result is NOT in the cell until the function ends. By definition, there would be no opportunity to apply individual character based formats within the function because there is no result until the function actually ends.

    However, that does not mean there is no solution here.
    It just means the solution needs to be two step.

    The first step is to use the custom concatenate function I've written ("ConcatSpecial") to build the unformatted string.
    The second step will be to click a button which will then convert all the formula results of the custom function to their text values (PasteSpecial.Values) and then parse through them to apply the custom formats.

    So, the reason I provide all this is to ask a question.

    Within the sample sheet you've provided, there is no apparent uniform way to programmatically identify where the necessary table will begin or end.

    You have two versions of the table, one with a single row and one with multiple rows.
    Additionally, you have several blank rows within the lower table.

    Programmatically it would be a simple matter to find the top row of the table and keep processing until it hits a blank row.
    However, with the inconsistencies in the sample workbook, this "easy way" is not possible.

    For purposes of making headway on my day off, I am going to "clean" the sample workbook to what I feel it should look like to be more "technically correct" and proceed.
    That is to say, I am going to remove the upper single row table and delete the blank rows from the lower table.

    If there is some reason why this would be a problem for your finished result, please let me know via update to this thread at your earliest convenient opportunity.

  6. #6
    Registered User
    Join Date
    10-04-2013
    Location
    Manila, Philippines
    MS-Off Ver
    Excel 2010
    Posts
    19

    Re: Concatenate Values | Retain Conditional Formatting of the Source

    Hello Bilbo_Baggins,

    The single row part above the table represents the "total" of the multiple rows part below it. The blanks rows between the multiple rows and the other two single rows below it were separated because they are on a different location (geographically). I think removing those blanks rows wouldn't be a big problem. We can just manually add the blanks rows when it is transferred to the email body for reporting.

    Additionally, the is another template with the same output format that I saw. However, instead of performing the formatting within the destination cell, it automatically opens a word file that contains the output data just as desired (with the font color), with blanks spaces in between rows. The problem is the codes were protected. No one cared to ask for the password before the author left. I hope this may trigger an idea as I am very new to VBA. I was only able to update other templates by copying and editing the codes to cope with the change/update. :p

    I really appropriate the time you spent trying to help me.

  7. #7
    Registered User
    Join Date
    10-04-2013
    Location
    Irving, Texas
    MS-Off Ver
    Office 2003-07-10-13
    Posts
    34

    Re: Concatenate Values | Retain Conditional Formatting of the Source

    OK, well, the end result is exactly what you sought, albeit achieved probably different from what you might have expected.

    So, for the first part, I wrote a custom function called “ConcatSpecial”
    Its arguments look like this in the cell “=ContatSpecial(AJ10:AO10)”
    This formula is typed in the home cell and then the 6 columns of data are selected just like any other function
    I did NOT write any error handlers for scenarios where you have text where it expects numbers.
    I’m assuming you know how and where to get properly expected values to the applicable ranges
    This custom function has all the normal functionality as any other built in function (copy/paste,FillDown,etc)

    For the second part, once you have the desired people and functions populated, there is a sub associated with the button “Apply Formats”
    Clicking the button will pull each person’s values, field by field and compare them against a new table I added on the “Parameters” sheet.
    The “Parameters” basically serves the same purpose as the existing conditional formats, but gives you better flexibility than the existing conditional formats.
    You now have the ability, if needed, to set different applicable values and color formats for each name.
    This includes any regional values you care to add to the table.
    The only error handler I built in manages a scenario where you have a name in the main section, but no matching name in the Parameters table.
    In this case, it simply tells you in the home cell this person needs parameters.

    This is not bomb proof and there are any number of ways it can be broken so I’ll not list them here.
    However, if you are partially handy with VBA, even if this does not necessarily exactly suit your needs, there is a good premise from which you can see and test ways to change it.

    Enjoy and let me know if you have any questions.
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    10-04-2013
    Location
    Irving, Texas
    MS-Off Ver
    Office 2003-07-10-13
    Posts
    34

    Re: Concatenate Values | Retain Conditional Formatting of the Source

    jcanlas,

    Just checking back to see if you've downloaded and tested the sample workbook I made.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. macro to merge values from one column into one cell and retain source formatting.
    By Scott Taylor in forum Excel Programming / VBA / Macros
    Replies: 21
    Last Post: 12-05-2012, 04:41 PM
  2. VBA to Retain the Conditional Formatting with an Advanced Filter
    By mmctague in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-12-2012, 02:09 PM
  3. Replies: 1
    Last Post: 08-16-2012, 10:51 AM
  4. Retain conditional formatting when pasting new data into cells, and how to copy it
    By NatGunod in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-03-2012, 10:27 AM
  5. Concatenate cells and retain formatting
    By NewYorkVanilla in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 09-20-2009, 02:17 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1