我正在尝试从另一个工作表而不是ActiveSheet
列出记录。有没有办法做到这一点?谢谢。
Public Sub CommandButton4_Click()
ListBox1.ColumnHeads = True
ListBox1.ColumnCount = 7
ListBox1.RowSource = "A2:G1000"
'Count the listbox rows when populated
With ActiveSheet
lastrow = .Range("A2", .Range("A" & .Rows.Count).End(xlUp)).Rows.Count
TextBox3 = lastrow
End With
End Sub
答案 0 :(得分:1)
赞:
Public Sub CommandButton4_Click()
ListBox1.ColumnHeads = True
ListBox1.ColumnCount = 7
ListBox1.RowSource = "A2:G1000"
Dim ws As Worksheet
Set ws = Sheets("Sheet1")
'Count the listbox rows when populated
With ws
lastrow = .Range("A2", .Range("A" & .Rows.Count).End(xlUp)).Rows.Count
TextBox3 = lastrow
End With
End Sub