lamojmohan
New Member
Private Sub CommandButton5_Click()
binnew = False
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
Trows = Worksheets("sheet2").Range("A1:A100").CurrentRegion.Rows.Count
For i = 2 To Trows
If Val(Trim(Worksheets("sheet2").Cells(i, 1).Value)) = Val(Trim(ComboBox1.Text)) Then
TextBox1.Text = Worksheets("sheet2").Cells(i, 1).Value
TextBox2.Text = Worksheets("sheet2").Cells(i, 2).Value
TextBox3.Text = Worksheets("sheet2").Cells(i, 3).Value
TextBox4.Text = Worksheets("sheet2").Cells(i, 4).Value
Exit For
End If
Next i
If TextBox1.Text = "" Then
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
Else
CommandButton1.Enabled = True
CommandButton2.Enabled = True
CommandButton7.Enabled = True
End If
End Sub
binnew = False
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
Trows = Worksheets("sheet2").Range("A1:A100").CurrentRegion.Rows.Count
For i = 2 To Trows
If Val(Trim(Worksheets("sheet2").Cells(i, 1).Value)) = Val(Trim(ComboBox1.Text)) Then
TextBox1.Text = Worksheets("sheet2").Cells(i, 1).Value
TextBox2.Text = Worksheets("sheet2").Cells(i, 2).Value
TextBox3.Text = Worksheets("sheet2").Cells(i, 3).Value
TextBox4.Text = Worksheets("sheet2").Cells(i, 4).Value
Exit For
End If
Next i
If TextBox1.Text = "" Then
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
Else
CommandButton1.Enabled = True
CommandButton2.Enabled = True
CommandButton7.Enabled = True
End If
End Sub