CONCATENATE different fonts in 1 cell

InfinityMrsn

New Member
Joined
Mar 21, 2023
Messages
15
Office Version
  1. 365
Platform
  1. Windows
Hi Everybody,

I am looking for a VBA code that can help me put 2 or 3 cells with different fonts in 1 cell. Tried many codes, but not what i'm looking for.

I would like in 1 cell a barcode (font I already have) with below it the description in text.

In column A I have the barcode (is a font), column B the article code and column C a location.

In cell D I managed to merge them with a formula, but the Font is forgotten. The result I am looking for is Cell E.

Hope somebody can help me.

Best regards,
Vanity
 

Attachments

  • Screenshot_excel_barcode.png
    Screenshot_excel_barcode.png
    65 KB · Views: 10

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Maybe the below VBA will help:
VBA Code:
Sub test()
    Dim rCell As Range  ' Declares a variable to represent each cell in the range
    
    For Each rCell In Range("A1:A" & Range("A" & Rows.Count).End(xlUp).Row).Cells
        ' Loop through each cell in the range
        With rCell
            .Offset(, 3) = Join(Array(.Value, .Offset(, 1).Value, .Offset(, 2).Value), vbNewLine)
            ' Concatenates the values of current cell, cell to the right, and cell two columns to the right
            ' The concatenated values are placed in the cell that is three columns to the right of the current cell
            With .Offset(, 3).Characters(1, Len(.Value))
                ' Targets the first line of the concatenated text within the cell
                .Font.Name = "Code 128"  ' Sets the font name to "Code 128"
                .Font.Size = 48  ' Sets the font size to 48 points
            End With
            .Offset(, 3).HorizontalAlignment = xlCenter  ' Aligns the cell contents horizontally to the center
        End With
    Next rCell
End Sub

I ran it on the below data (Barcode fornt not supported on XL2BB):
Book1
ABCD
1Hello WorldHello World1.2.3Hello World Hello World 1.2.3
2Hello WorldHello World1.2.4Hello World Hello World 1.2.4
Sheet1
Cell Formulas
RangeFormula
A1:A2A1=B1
 
Upvote 0
Solution

Forum statistics

Threads
1,215,461
Messages
6,124,952
Members
449,198
Latest member
MhammadishaqKhan

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