简短且(希望)简单的问题,我搜索了工作表范围以找到特定的参考编号,然后想要使用下面的代码片段从左侧搜索该行中的第一个空白单元格的范围(其中我从这个问题发展而来:mrExcel help site)
Set projectSearchRange = Sheets("Milestones").Range("A:A").Find(projectref, , xlValues, xlWhole)
current_row = projectSearchRange.Row
Set searchrange = Sheets("Milestones").Range(Sheets("Milestones").Cells(current_row, 2), Sheets("Milestones").Cells(current_row, 23)).SpecialCells(xlCellTypeBlanks).Cells(1).Activate
milestoneduedate = ActiveCell.Offset(, 1).Value
然而,“设置搜索范围”行正在抛出运行时424 - 对象所需的错误,但据我所知,我已正确地写了这行。
对于我做错了什么的任何见解都将不胜感激。
答案 0 :(得分:2)
这应该适合你。
函数MilestoneDueDate()As Variant
Dim projectSearchRange As Range Dim Current_Row As Long Dim SearchRange As Range With Sheets("Milestones") Set projectSearchRange = .Range("A:A").Find(projectref, , xlValues, xlWhole) Current_Row = projectSearchRange.Row Set SearchRange = .Range(Cells(Current_Row, 2), Cells(Current_Row, 23)) _ .SpecialCells(xlCellTypeBlanks).Cells(1) End With MilestoneDueDate = SearchRange.Offset(0, 1).Value
结束功能