Board logo

標題: Excel VBA 問題 [打印本頁]

作者: qmk292    時間: 2017-4-17 20:23     標題: Excel VBA 問題

各位師兄, 我自己試下寫VBA, 但佢不停彈出稷話要陳述式結尾, 請問應該怎樣?

Private Sub CommandButton_Addnewrecord_Click()

'find first empty row in database
iRow = ws.Cells.Find(What:="*", SearchOrder:=xlRows, _ SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1

'check for a Order number
If Trim(Me.TextBox_orderno.Value) = "" Then
Me.textbox_ OrderNo.SetFocus
MsgBox "Please complete the form"
Exit Sub
End If

'copy the data to the database
ws.Cells(iRow, 1).Value = Me.textbox_ orderno.Value
ws.Cells(iRow, 2).Value = Me.textbox_ quotationdate.Value
ws.Cells(iRow, 3).Value = Me.textbox_ salesstaff.Value
ws.Cells(iRow, 4).Value = Me.textbox_ price.Value
ws.Cells(iRow, 5).Value = Me.textbox_ depositamount.Value
ws.Cells(iRow, 6).Value = Me.textbox_ deposittype.Value
ws.Cells(iRow, 7).Value = Me.textbox_ client1.Value
ws.Cells(iRow, 8).Value = Me.textbox_ tel1.Value
ws.Cells(iRow, 9).Value = Me.textbox_ olddistrict.Value
ws.Cells(iRow, 10).Value = Me.textbox_ Oldstreet.Value
ws.Cells(iRow, 11).Value = Me.textbox_ Oldbuilding.Value
ws.Cells(iRow, 12).Value = Me.textbox_ Oldblock.Value
ws.Cells(iRow, 13).Value = Me.textbox_ Oldfloor.Value
ws.Cells(iRow, 14).Value = Me.textbox_ Oldunit.Value
ws.Cells(iRow, 15).Value = Me.textbox_ Remarks.Value
作者: myricky    時間: 2017-4-18 11:13

提示: 作者被禁止或刪除 內容自動屏蔽
作者: 狂蜂一號    時間: 2017-4-19 02:13

回覆 1# qmk292

ws.Cells(iRow, 1).Value = Me.textbox_orderno.Value





歡迎光臨 電腦領域 HKEPC Hardware (https://h2.hkepc.com/forum/) Powered by Discuz! 7.2