Share via

How to Dynamically Show and Size Formatted Text Being Referenced

Anonymous
2022-12-01T14:54:24+00:00

Good Morning!

I have a very specific job parameter that seems to be harder to achieve than I think it should be.

Basically, I am using Excel to generate labels/placards that use information from another table. Each label is a single cell that is referencing an entire table column, which is easy enough to do with added line breaks in between to separate said information. The difficult part comes with formatting the text as each "line" within a label cell needs different formatting. For example:

Name 1<br><br>Description 1

would be generated from:

Label
Name Name 1
Description Description 1

While I understand how to make the first table out of two cells and "faked" to appear as a single one, the issue comes from the fact that each label has a static size (2.5" in this case), the text needs to be justified both horizontally and vertically, as well as each line within the cell having different formatting, AND each label may have anywhere from three to seven rows so it's justification will be dynamic.

I am able to reference and create the labels from a purely data standpoint, but it means that I cannot format each line of text within the cell (font size, italicized, etc.), inside of the formula bar. To elaborate on what exactly I did to achieve that, this is my formula:

=Input!B1&IF(ISTEXT(Input!B2),CHAR(10)&Input!B2,"")&IF(ISTEXT(Input!B3),CHAR(10)&Input!B3,"")&IF(ISTEXT(Input!B4),CHAR(10)&Input!B4,"")&IF(ISTEXT(Input!B5),CHAR(10)&Input!B5,"")&IF(ISTEXT(Input!B6),CHAR(10)&Input!B6,"")&IF(ISTEXT(Input!B7),CHAR(10)&Input!B7,"")

Where "B1" is the first cell of data on a table within the sheet "Input". A little janky but it's mostly formatted to not add line breaks if a referenced cell is empty. With this I have exactly what I need besides the lines being visually formatted to be bold or larger or italicized.

Is there a way to achieve this through different means? I haven't found much information beyond some very specific VBA code but it seems I can't format text that way within the formula bar unfortunately.

If any elaboration is needed I would be happy to do so, thanks in advance for the help!

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

2 answers

Sort by: Most helpful
  1. Anonymous
    2022-12-01T15:40:18+00:00

    Which is what I was worried about.

    I am open to ideas on how to achieve the same effect through different means, it can be in different cells in the end if it formats the same way.

    Thanks

    Was this answer helpful?

    0 comments No comments
  2. HansV 462.6K Reputation points
    2022-12-01T15:03:04+00:00

    It is impossible to format parts of the result of a formula differently from the rest of the output.

    It is only possible to format individual parts of the contents of a cell if that cell contains a value, not if it contains a formula.

    Was this answer helpful?

    0 comments No comments