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