在這里,我嘗試創建一些用戶表單來更新我的資料表。我有這個資料表(點擊率摘要資訊)來提供基本資訊,因為我有很多列要填寫,將所有資訊放在一個表格中會有點混亂。所以我根據需要更新的部分將其拆分為表單的某個部分。

如果我單擊更新命令按鈕,它將重定向到更新表單并從串列框中提取我需要的資料資訊部分。像下面的圖片

從文本框中更改我的值并單擊更新后,它給了我錯誤 Application.WorksheetFunction.Match Unable to get the Match Property of the Work。這是我的代碼
Private Sub UPDATE_Click()
If MsgBox(" Check the Data Again ", vbYesNo, "Proceed to Subcontractor Form Information if Any") = vbYes Then
' write the data to the worksheet from controls
Call WriteDataToTheSheet
' empty the textboxes
Call EmptyTextBoxes
Else
' empty the textboxes
Call EmptyTextBoxes
End If
End Sub
'UPDATE CODE
Private Sub WriteDataToTheSheet()
With Sheet2
Dim selectedRow As Long
LRow = .Range("A" & .Rows.Count).End(xlUp).row
selectedRow = Application.WorksheetFunction.Match(WONUMBER.Value, Sheet2.Range("I2:I" & LRow), 0)
.Cells(selectedRow, 1).Value = Now
.Cells(selectedRow, 2).Value = NAMACLIENT.Value
.Cells(selectedRow, 3).Value = BLANKETNUMBER.Value
.Cells(selectedRow, 4).Value = CTRNUMBER.Value
.Cells(selectedRow, 5).Value = PICBIRU.Value
.Cells(selectedRow, 6).Value = PICCLIENT.Value
.Cells(selectedRow, 7).Value = PROJECTSTATUS.Value
.Cells(selectedRow, 8).Value = PROJECTTITLE.Value
.Cells(selectedRow, 9).Value = WONUMBER.Value
.Cells(selectedRow, 10).Value = WODIR.Value
.Cells(selectedRow, 11).Value = WOSTARTDATE.Value
.Cells(selectedRow, 12).Value = WOENDDATE.Value
.Cells(selectedRow, 13).Value = REMARKS.Value
.Cells(selectedRow, 14).Value = WAPU.Value
.Cells(selectedRow, 17).Value = ENGVALUE.Value
.Cells(selectedRow, 18).Value = REIMBURSABLE.Value
End With
End Sub
Can you tell me what I am doing wrong? I just started a couple weeks ago in vba and I make this code from different kind of youtube references. I just really stuck in this one. I'm really appreciate your help.
EDIT:
sorry to gave you minimal information
this is my excel data image

This is my debugging code image

uj5u.com熱心網友回復:
作業表上是 WONUMBERS 數字嗎?如果是這樣,您需要將用戶表單中文本框中的文本 WONUMBER 轉換為數字,您可以使用 Val 來完成。
selectedRow = Application.Match(Val(WONUMBER.Value), Sheet2.Range("I2:I" & LRow), 0)
或者,您可以在更新表單上添加一個隱藏的文本框,用在前一個表單中選擇的行填充它,并在更新時使用它。
uj5u.com熱心網友回復:
或者,您可以將搜索值放入某個作業表上的單元格中,并在匹配陳述句中使用該單元格。該作業表可以隱藏。
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/324382.html
