userform1. code works perfect when sheet "All p.o. info" is active, but issues when sheet is not active. textbox value not showing or showing wrong information when sheet with range containing the value is inactive. Any help will be greatly appreciated.
`Private Sub CommandButton4_Click()
Dim id As String
Dim PO As String
Dim finalrow As Integer
Dim i As Integer
id = TextBox16.Value
finalrow = Sheets("ALL P.O. INFO").Range("D6000").End(xlUp).ROW
For i = 2 To finalrow
If Sheets("ALL P.O. INFO").Cells(i, 4) = id Then
Me.TextBox23 = Sheets("ALL P.O. INFO").Cells(i, 7).Value
Me.TextBox19 = Sheets("ALL P.O. INFO").Cells(i, 4).Value
Me.TextBox20 = Sheets("ALL P.O. INFO").Cells(i, 1).Value
Me.TextBox21 = Sheets("ALL P.O. INFO").Cells(i, 6).Value
Me.TextBox22 = Sheets("ALL P.O. INFO").Cells(i, 14).Value
End If
PO = TextBox18.Value
finalrow = Sheets("ALL P.O. INFO").Range("A6000").End(xlUp).ROW
If Cells(i, 1) = PO Then
Me.TextBox23 = Sheets("ALL P.O. INFO").Cells(i, 7).Value
Me.TextBox19 = Sheets("ALL P.O. INFO").Cells(i, 4).Value
Me.TextBox20 = Sheets("ALL P.O. INFO").Cells(i, 1).Value
Me.TextBox21 = Sheets("ALL P.O. INFO").Cells(i, 6).Value
Me.TextBox22 = Sheets("ALL P.O. INFO").Cells(i, 14).Value
End If
Next i`