Updating text in shape using data entered in a textbox in userform.

ashni

New Member
Joined
Jun 13, 2016
Messages
32
HII!!
I have a shape and it has this text in the shape:-

ID: 1648280
Title: NR Analysis and report for colon 2016_12
Completed work: 7
Remaining work: 3

Now i Have a userform which appears after selecting the shape. and it has one text box with label completed work and one button - Save.

Now when i enter the value in the textbox and save it the shape should update to following text:-

ID: 1648280
Title: NR Analysis and report for colon 2016_12
Completed work:
'​value user enters in UserForm1 textbox'
Remaining work: 0

How do i do it?
 
using split, left and replace function:-

Code:
Private Sub CommandButton1_Click()
Dim FrameText   As String
Dim ReplaceText As Variant
Dim newText     As String
Dim x           As Integer
Dim NEWSTRING As String
'ActiveSheet.Shapes.Range(Array("Rectangle 10")).Select
FrameText = Selection.ShapeRange(1).TextFrame2.TextRange.Characters.Text
ReplaceText = Split(FrameText, Chr(10))
'Debug.Print ReplaceText(2)
newText = "Completed Work: " & CInt(UserForm1.TextBox1.Text)
FrameText = Replace(FrameText, ReplaceText(2), newText)
NEWSTRING = Left(FrameText, Len(FrameText) - 2)
Selection.ShapeRange(1).TextFrame2.TextRange.Characters.Text = NEWSTRING & "0"
Range("A1").Select
Unload Me
End Sub
 
Upvote 0

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