J
Jack_Feeman
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
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