0
我有一個帶有兩個文本框的小型用戶窗體。我需要的是,當我按下提交按鈕時,它會爲我運行一個代碼,最後它應該激活名稱在textbox2中輸入的工作表。到目前爲止,我已經經歷了所有階段,但無法完成最後一步。使用文本框選擇工作表的代碼
這裏是我的代碼:
Private Sub CommandButton1_Click()
'Defining the Variables
Dim ws As Worksheet
Dim tbl As ListObject
Dim row As ListRow
Dim sample As Worksheet
'Assigning the Variables
Set ws = UserForm2.txt2.Value
Set tbl = ws.ListObjects(1)
Set row = tbl.ListRows.Add(Alwaysinsert:=True)
'Setting Up the Range and Enter Data in Table
lastrow = ws.Range("A:A").End(xlUp).row
row.Range(1, 1).Value = txt1.Value
'Create the New Sheet for the Account Head Created
Sheets("Summary-CH-Sample").Copy After:=Sheets(Sheets.Count)
Set sample = ActiveSheet
sample.Name = UserForm2.txt1.Value
'Entering the Sheet name in Newly Created Sheet
With ActiveSheet
Range("A7").Value = "Summary of " & UserForm2.txt1.Value
End With
請幫助我。
感謝 薩爾曼·汗