|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
各位老师好:下述代码需要将活动的工作表Cells(Rows.Count, 2).End(xlUp).Row 改成调用其他工作表。
改了几次都没有很好的解决。 如:LastRow = Sheet2.UsedRange.Rows.Count
或者能直接调用同文件目前下的其他文件。
求助0810.rar
(19.01 KB, 下载次数: 1)
Private Sub TextBox1_Change()
Dim Arr() As Variant
Dim LastRow As Long, Count As Long, i As Long
LastRow = Cells(Rows.Count, 2).End(xlUp).Row
ReDim Arr(1 To 7, 1 To LastRow)
Count = 1
For i = 2 To LastRow
If Cells(i, "B") = TextBox1.Text Then
Arr(1, Count) = Cells(i, "A")
Arr(2, Count) = Cells(i, "B")
Arr(3, Count) = Cells(i, "C")
Arr(4, Count) = Cells(i, "D")
Arr(5, Count) = Cells(i, "E")
Arr(6, Count) = Cells(i, "F")
Arr(7, Count) = Cells(i, "G")
Count = Count + 1
End If
Next
ReDim Preserve Arr(1 To 7, 1 To Count)
ListBox1.ColumnCount = 7
ListBox1.ColumnWidths = "50,40,50,50,50,80,20"
ListBox1.List = Application.Transpose(Arr)
End Sub
|
|