• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

How to format different cells together inside a text box using VBA

Rameez Sarang

New Member
Hi All,

I am trying to combine 3-4 cells with different values & format together inside a shape using VBA but not able to do so.

Please can some suggest me a code for this. I have attached the file and also given as to what should be the final output. Also the data is not same and trends to change for every report.

Can anyone please help?

Thanks,
Rameez
 

Attachments

Marc L

Excel Ninja
Hi,​
first you must well format the text properties of the shape like the font color & size, etc …​
For starters this is a VBA demonstration to allocate the cells text to the shape :​
Code:
Sub Demo1()
         Dim S$
    With Sheet1
         S = " " & .[G8].Text & " "
        .Shapes(1).TextFrame.Characters.Caption = .[G4].Text & vbLf & .[G5].Text & S & .[G6].Text & S & .[G7].Text
    End With
End Sub
Do you like it ? So thanks to click on bottom right Like !​
 

Rameez Sarang

New Member
Thanks a lot this is working. The only thing is can the colour of text be changed to black and alignment to center inside the text box.
 

Marc L

Excel Ninja
No need to do it under VBA as I wrote « first you must well format the text properties of the shape like the font color & size, etc … »​
 
Top