[英]VBA Excel: Error 400 on Cells.Value
我在以下函數中的Cells.Value上收到400錯誤:
Function Add_Buttons(myColumn)
Dim btn As Button
ActiveSheet.Buttons.Delete
Dim t As Range
'Search for last row
lastRow = Cells(Rows.Count, 1).End(xlUp).Row
'Force-Update
Application.Calculate
'Generate a button for each cell, if it's not empty
For i = 3 To lastRow
Set t = Range(Cells(i, myColumn), Cells(i, myColumn))
If Cells(i, t.column - 1).Text = "Nicht OK" Then
Set btn = ActiveSheet.Buttons.Add(t.Left, t.Top, t.Width, t.RowHeight)
With btn
.OnAction = "'DieseArbeitsmappe.Update_DB """ & ActiveSheet.Cells(i, myColumn).Value & """'" 'THIS IS WHERE THE ERROR OCCURS
.Caption = "Update"
.Name = "Btn_" & ActiveSheet.Name & "_" & i
End With
End If
Next i
End Function
我在代碼中找不到任何錯誤。 肯定是帶有ActiveSheet.Cells(i, myColumn).Value
,因為沒有此參數, .OnAction
可以正常工作。
我知道了 如果您遇到類似的情況,請確保單元格中的引號已轉義。 這樣您可以避免此錯誤。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.