userform1。当工作表“所有邮政信息”处于活动状态时,代码可以完美工作,但在工作表处于非活动状态时,该代码会出现问题。当具有包含该值的范围的工作表处于非活动状态时,文本框值不显示或显示错误信息。任何帮助将不胜感激。
`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`