0
我有一个宏为前36行工作,但然后显示运行时91错误。它显示find语句中的错误。宏的目的是计算列中数据的第90百分位数,计算等于或大于百分位的值的数量,并提供各部门之间的划分。任何人都可以帮我纠正错误吗?VBA运行时错误91 - 2
For bb = 1 To temcnt
cc = Sheets("tem").Cells(bb, ttc + 4).Value
Sheets("Geographic Strength").Activate
Cells.Find(What:=cc, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate
ff1 = ActiveCell.Column
Sheets("tem").Activate
rnggg = Range(Cells(2, 6), Cells(ttr, 6))
mamm = WorksheetFunction.CountIf(Range(Cells(2, 6), Cells(ttr, 6)), cc)
Sheets("geographic strength").Activate
f222 = Sheets("individual strength").Cells(1, iii).Value
**Cells.Find(What:=f222, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate
f333 = ActiveCell.Row**
'Error is in the above statement(Cells.Find)
Cells(f333, ff1).Value = mamm
Next bb
Sheets("tem").Delete
Next iii
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
使用'.Activate','.Select'等通常是一个坏主意b因为它会放慢宏观并增加犯错的风险。 [Here](http://stackoverflow.com/questions/10714251/how-to-avoid-using-select-in-excel-vba-macros)和[here](http://stackoverflow.com/documentation/excel -vba/1107/vba-best-practices/9292/avoid-using-select-or-activate)是如何避免它的一些提示。 – arcadeprecinct