0
有人可以幫助我更正我的代碼,因爲我無法在用戶表單工作中創建我的更新按鈕。下面是我的代碼:如何使用vba excel更新數據
Private Sub CommandButton_update_Click()
Dim cNum As Integer
Dim x As Integer
Dim nextrow As Range
cNum = 7
Set nextrow = Sheet1.Cells(Rows.Count, 3).End(xlUp).Offset(1, 0)
For x = 1 To cNum
nextrow = Me.Controls("TextBox" & x).Value
Set nextrow = nextrow.Offset(0, 1)
Next
MsgBox "Sent"
'Clear Control
cNum = 7
For x = 1 To cNum
For x = 1 To cNum
nextrow = Me.Controls("TextBox" & x).Value = ""
Set nextrow = nextrow.Offset(0, 1)
Next
End Sub
你的代碼是** **不可編譯的,你有2個'對於x = 1至cNum'只有1' Next' –
爲了澄清,您有一個帶有7個文本框的用戶窗體,您希望將其放入Sheet1列C中,那麼您希望在不卸載用戶窗體的情況下清除這些文本框? –