Editing text copied into a cell by a UserForm

G

Guest

I really appreciate the help I received here on the first part of this form,
it works fine.

My problem now is if the cells where the userform was used to populate them
needs to be edited in the same way, how can I code the UserForm to check the
appropriate cell and load its content if it is not empty? Then the user would
edit it and click OK to save the edited text back to the cell.

This is the code behind the UserForm as it is now:
Quote:

Private Sub CommandButton1_Click()
Unload Me
End Sub
Private Sub CommandButton2_Click()
Dim myStr As String
myStr = Replace(Me.TextBox1.Value, vbCr, "")
'for it to be treated as text
Sheets("Evaluation").Range("B25:H25").Value = "'" & myStr
Unload Me
End Sub

Private Sub Label1_Click()

End Sub

Private Sub TextBox1_Change()
Dim myMax As Long
Dim myMsg As String

myMax = 927

myMsg = "Length: " & Len(Me.TextBox1.Value) _
& " Remaining: " & _
Application.Max(0, myMax - Len(Me.TextBox1.Value))

Me.Caption = myMsg
End Sub
Private Sub UserForm_Initialize()

With Me.TextBox1
.WordWrap = True
.MultiLine = True
.EnterKeyBehavior = True
.Value = ActiveCell.Value
End With
With Me.CommandButton1
.Caption = "Cancel"
.Cancel = True
End With
Me.CommandButton2.Caption = "Ok"
End Sub

Unquote

Thanks for all your help. Jack
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top