VBA:命名的参数未find,多个.Finds

我一直在试图让VBAsearch一列单元格(这将是用户填充)来find特定的标准。 经过与WorksheetFunction.CountIfs的挣扎(我已经解决了这个代码,到目前为止,它似乎工作:

Sub CalendarColor() Call VarDef Dim SearchEmpList As Range Dim SearchSDate As Range Dim SearchEDate As Range Dim SearchLType As Range Dim SearchPType As Range If EmpName <> "" Then With Worksheets(2).Range("B:B") 'Search all of Employee Name list entries Set SearchEmpList = .Find(What:=EmpName, _ After:=.Cells(.Cells.Count), _ LookIn:=xlValues, _ LookAt:=xlWhole, _ SearchOrder:=xlByRows, _ SearchDirection:=xlNext, _ MatchCase:=False) End With 

所以这是第一列和第一个必须确定的variables。 要进入相关的开始date,我添加了以下代码:

  With Worksheets(2).Range("C:C") 'Search all of Start Date list entries Set SearchSDate = .Find(What:=ActiveCell.Value, _ After:=.Cells(.Cells.Count), _ LookIn:=xlValues, _ LookAt:=xlWhole, _ SeachOrder:=xlByRows, _ SeachDirection:=xlNext, _ MatchCase:=False) End With 

在我看来,这是完全一样的,但我得到了“运行时错误'448':命名参数找不到”当使用步入debugging。

它是ActiveCell.Value吗? 如果是这样,我还能使用什么? 这个脚本将被用在一个循环脚本中,每次迭代都会抵消一个循环 – 所以ActiveCell似乎是最合理的,如果它工作的话。

循环脚本如下所示:

 Sub ColorLoop() Dim EndNumberA As Integer '31 day months Dim EndNumberB As Integer '30 day months Dim EndnumberC As Integer '28 day months Dim EndNumberD As Integer '29 day months Dim i As Integer EndNumberA = 31 EndNumberB = 30 EndnumberC = 28 EndNumberD = 29 'Offset commands need to be tweaked each year to ensure the ActiveCell lands on the first day of the next month 'January 31d For i = 1 To EndNumberA Call CalendarColor ActiveCell.Offset(, 1).Select Next i 'Set ActiveCell to Feb1 ActiveCell.Offset(1, -28).Select 'February 28d (Use EndNumberD if leap year) For i = 1 To EndnumberC 'Call CalendarColor ActiveCell.Offset(, 1).Select Next i 'Set ActiveCell to Mar1 ActiveCell.Offset(1, -28).Select 

我在学习VBA(和我在这里的第一篇文章)大约2周,所以无论你有什么是欢迎的信息。

 SeachOrder:=xlByRows, _ SeachDirection:=xlNext, _ 

那些是错别字。 search不是search!