Hello all,
I'm having trouble with a form I've created. My form consists of
combobox and several textboxes which displays data from workshee
"METRO". Once the form is displayed, data can also be changed. Th
trouble is I have 2 textboxes that will not write back to the asigne
cell. One of the trouble textboxes enters 2 digit numbers and th
other is a date field. Below is example of my code. Any advice woul
be greatly appreciated.
Private Sub Userform_Initialize()
Dim r As Long
Dim ws As Worksheet
Set ws = Worksheets("METRO")
r = ws.Cells(1, 14).End(xlUp).Offset(1, 0).Row
ComboBox4.Value = ws.Cells(r, "G").Value
ComboBox4.SetFocus
End Sub
Private Sub combobox4_Click()
Dim dt As Long
With crit
If .ComboBox4.ListIndex = -1 Then Exit Sub
For Each Cell In Worksheets("METRO").Range("G2:G400")
dt = ComboBox4.Value
If Cell.Text = dt Then
TextBox1.Value = Cell.Offset(0, -3).Text
TextBox2.Value = Cell.Offset(0, -5).Text
End If
Next
End With
End Sub
Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
With Worksheets("METRO")
Set rng = .Range("G2:G400")
End With
res = Application.Match(CLng(ComboBox4.Value), rng, 0)
If Not IsError(res) Then
rng(res).Offset(0, -3).Value = TextBox1.Text
End If
End Sub
Private Sub TextBox2_Exit(ByVal Cancel As MSForms.ReturnBoolean)
With Worksheets("METRO")
Set rng = .Range("G2:G400")
End With
res = Application.Match(CLng(ComboBox4.Value), rng, 0)
If Not IsError(res) Then
rng(res).Offset(0, -5).Value = TextBox2.Text
End If
End Sub
Thank
--
Message posted from
http://www.ExcelForum.com