View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Mike H Mike H is offline
external usenet poster
 
Posts: 11,501
Default VBA Userform Textbox help

Hi,

I may have misunderstood but if all you want to do is copy the contents of
the texbox tp A1 then this will do it:-

Private Sub CommandButton1_Click()
Dim r As Range
Set r = ActiveWorkbook.Worksheets("Comments1").Range("A1")
b = Me.TxtBox1.Text
r.Value = b
End Sub


Mike

"Joey_83" wrote:

Hi All,
This might sound like a dumb question (which it probably is) but can
someone help me with the below code?

I have a userform called NCCC1 and I want to copy the text (which is
over 255 characters) from the textbox to a cell. I am getting an
object required error message and I can only seem to find help for
copying from drawing textboxes not userform textboxes.
Is there a difference?

Private Sub btnSave_Click()

Application.ScreenUpdating = False
Dim r As Range
Dim b As Variant
Dim i As Integer

Set r = ActiveWorkbook.Worksheets("Comments1").Range("A1")
b = Me.txtbox1.Text
'--codes breaks here--
r.Value = b.Characters(1, 255).Text
For i = 256 To b.Characters.Count Step 255
r.Value = r.Value & b.Characters(i, 255).Text
Next i
r.WrapText = False

End Sub