簡體   English   中英

如何在Excel-VBA中的表單上顯示工作表

[英]How to display a worksheet on a form in excel-vba

我正在嘗試在表單上顯示工作表,但直到現在我都沒有成功。 該工作表包含15列和大約2000行。 有人能幫我嗎?

建立一個帶有列表框和一個按鈕的表單。 然后將此代碼放入表單模塊。 該按鈕應命名為CommandButton1,並且列表框應命名為ListBox1。

最后,在列表框控件上,將columncount更改為15。

Private Sub CommandButton1_Click()
    Unload Me
End Sub


Private Sub UserForm_Initialize()
    ' Activate the sheet that has the data you want displayed in the listbox
    Sheet1.Activate
    ' Put the range of the data you want displayed.
    ' Here I used columns "A" to "O" and 2000 rows
    ListBox1.RowSource = "A1:O2000"
End Sub

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM