-1
我是新來的宏,並希望從工作表中的範圍中找到文本或文本的一部分,我研究並發現此代碼:VBA Excel宏運行時錯誤'1004'當試圖.Find()
Set aCell = .Columns(1).Find(What:="Custom ", LookIn:=xlValues, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
但是,當我運行,它給了我1004錯誤。所以這是我的全部子:
Sub kl()
Dim ws As Worksheet
Dim aCell As Range
Set ws = ThisWorkbook.Sheets("te-dhenat")
With ws
Set aCell = .Columns(1).Find(What:="Custom ", LookIn:=xlValues, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
If Not aCell Is Nothing Then
aCell.Value = "Test"
Else
MsgBox "Not Found"
End If
End With
End Sub
我覺得代碼看起來很好,所以我不知道爲什麼Excel是顯示這個錯誤,請幫忙,謝謝你提前
代碼看起來確定。它失敗的是什麼? – brettdj
表單是否受到保護? – Rory
@brettdj,它在set aCell上的失敗= .Columns(1).Find(..... –