View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Charles Charles is offline
external usenet poster
 
Posts: 1
Default Adding up values of textbox in Userform

Mark,

Here is what I came up with.

Private Sub CommandButton1_Click()
Application.ScreenUpdating = False
Dim i As Long
Dim myrng As Range
Worksheets("sheet1").Activate
Set myrng = Worksheets("sheet1").Cells(1, 1).CurrentRegion
For i = 1 To myrng.Rows.Count
Next i
With UserForm1
myrng(i, 1).Value = .TextBox3.Text
End With
End Sub

Private Sub TextBox2_KeyDown(ByVal KeyCode As MSForms.ReturnInteger
ByVal Shift As Integer) 'tab key
Application.ScreenUpdating = False
Dim tb1 As Long
Dim tb2 As Long
If KeyCode = "9" Or KeyCode = "13" Then
tb1 = TextBox1
tb2 = TextBox2
With UserForm1
.TextBox3.Value = tb1 + tb2
End With
End If
End Sub

Every time you tab or hit the enter key on textbox2 the value o
textbox3 changes.
Click the commandbutton and it put texbox3 to the worksheet.

HTH

Charle

--
Message posted from http://www.ExcelForum.com