Banner

Wednesday, February 15, 2017

Worksheet Data Edit From Userform EXcell VBA





Textbox Format
Private Sub TextBox1_AfterUpdate()
On Error Resume Next
Me.TextBox1 = CDate(Me.TextBox1)
End Sub
Private Sub TextBox3_AfterUpdate()
On Error Resume Next
Me.TextBox3.Value = StrConv(Me.TextBox3.Value, vbProperCase)
End Sub
Private Sub TextBox4_AfterUpdate()
On Error Resume Next
Me.TextBox4.Value = Format(Me.TextBox4.Value, "#####.00")
End Sub
Worksheet To Userform
Private Sub TextBox5_AfterUpdate()
Dim i As Long
For i = 2 To Application.WorksheetFunction.CountA(Sheet1.Range("A:A"))
For x = 1 To 4
If Sheet1.Cells(i, "B").Value = Me.TextBox5.Text Then
Me("Textbox" & x).Value = Sheet1.Cells(i, x).Value
End If
Next x
Next i
End Sub
Userform To worksheet
Private Sub CommandButton1_Click()
Dim i As Long
For i = 2 To Application.WorksheetFunction.CountA(Sheet1.Range("A:A"))
For x = 1 To 4
If Sheet1.Cells(i, "B").Value = Me.TextBox5.Text Then
Sheet1.Cells(i, x).Value = Me("Textbox" & x).Value
End If
Next x
Next i
End Sub

No comments:

Post a Comment

Please do not enter any spam message in comment box