VBA text box source from cells

mrmrf

New Member
Joined
Jun 3, 2019
Messages
34
Hi.

The below VBA is part of a code to create a text box and populate with content from two cells however I’m looking to alter to include:

The cell V9, contains a number 0.5, and the cell is formatted as a percent, 50%. I need the above code to present as a percent in the text box rather than the decimal number

Also, how do I specify the data from each cell to be on a new line within the textbox?

Thanks!

Code:
     Set L1wL = ActiveSheet.Shapes.AddTextbox(msoTextOrientationHorizontal, 380, L1y4 - 5, 200, 20)                
                L1wL.TextFrame.Characters.Text = Range("U9").Value & Range("V9").Value
                L1wL.Name = "L1Line3"
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Hi,

if you are referring to a text box in a Userform or from developer tab, try this

Sub L1wL_exit (byval cancel as MSForms.ReturnBoolean)
L1wL.value = Format(L1wL.value) / 100
end sub
 
Upvote 0
Thank you VBE313, i was able to solve along your lines of "format"

Any ideas now how to specify it should be in the next line of the text box?

Thanks

Code:
     Set L1wL = ActiveSheet.Shapes.AddTextbox(msoTextOrientationHorizontal, 380, L1y4 - 5, 200, 20)                
                L1wL.TextFrame.Characters.Text = Range("U9").Value & FormatPercent(Range("V9").Value)
                L1wL.Name = "L1Line3"
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,196
Members
452,616
Latest member
intern444

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