簡體   English   中英

VBA For帶有用戶窗體文本框的語句

[英]VBA For statement with userform textbox

我正在使用用戶窗體輸入數據,並使用以下代碼將數據傳輸到excel:

    Cells(1,1).Value = Textbox1.Value
    Cells(1,2).Value = Textbox2.Value
    Cells(1,3).Value = Textbox3.Value
......
    Cells(1,57).Value = Textbox57.Value
    Cells(1,58).Value = Textbox58.Value
    Cells(1,59).Value = Textbox59.Value

我將簡化以下內容

Dim i As integer

For i = 1 to 59
Cells(1,i).Value = "Textbox" & i.Value
Next

但是“文本框”和i.Value部分發生錯誤

請提出建議,謝謝

這應該工作,

Dim i As Long

For i = 1 to 59
Cells(1,i).Value = Me.Controls("TextBox" & i).Value
Next

暫無
暫無

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

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