VBA发现不能在合并的单元格上工作

美好的一天,我发现functionfind没有合并的单元格,但没有合并单元格A列工作。它会引发运行时错误'91',对象variables或块variables未设置。

Ret1 = Application.GetOpenFilename("Excel Files (*.xls*), *.xls*", _ , "Please select file") If Ret1 = False Then Exit Sub Set wb2 = Workbooks.Open(Ret1) With wb2.Sheets(1) firstrow = .Range("A:A").find(what:="Total", after:=.Range("A1")).Row + 1 End With 

下面应该为你解决这个问题:

 With wb2.Sheets(1) firstrow = .Range("A:A").find(what:="Total", after:=.Range("A1")).MergeArea.Cells(1,1).Row + 1 End With