感谢Noodles的回答,我知道我的UDF是我的Excel工作簿中滞后的主要原因。是否可以重写此UDF以避免延迟?我正在使用这个带有excel公式的UDF(例如= IF(OR(ISNUMBER($ DH2),$ DH2>""),LookUpConcat($ B2,用法!$ AM $ 2:$ AM $ 5000,用法!$ AS $ 2:$ AS $ 5000,""),""))。也许公式需要改变。公式通过许多单元格下拉,并调整为在工作簿中的2个不同列中工作。我不是IT所以面条回答我的最后一个滞后问题并不完全被我理解,但给了我足够的信息,知道这是导致最滞后问题的宏。
Function LookUpConcat(ByVal SearchString As String, SearchRange As Range, ReturnRange As Range, _
Optional Delimiter As String = " ", Optional MatchWhole As Boolean = True, _
Optional UniqueOnly As Boolean = False, Optional MatchCase As Boolean = False)
Dim X As Long, CellVal As String, ReturnVal As String, Result As String
If (SearchRange.Rows.Count > 1 And SearchRange.Columns.Count > 1) Or _
(ReturnRange.Rows.Count > 1 And ReturnRange.Columns.Count > 1) Then
LookUpConcat = CVErr(xlErrRef)
Else
If Not MatchCase Then SearchString = UCase(SearchString)
For X = 1 To SearchRange.Count
If MatchCase Then
CellVal = SearchRange(X).Value
Else
CellVal = UCase(SearchRange(X).Value)
End If
ReturnVal = ReturnRange(X).Value
If MatchWhole And CellVal = SearchString Then
If UniqueOnly And InStr(Result & Delimiter, Delimiter & ReturnVal & Delimiter) > 0 Then GoTo Continue
Result = Result & Delimiter & ReturnVal
ElseIf Not MatchWhole And CellVal Like "*" & SearchString & "*" Then
If UniqueOnly And InStr(Result & Delimiter, Delimiter & ReturnVal & Delimiter) > 0 Then GoTo Continue
Result = Result & Delimiter & ReturnVal
End If
Continue:
Next
LookUpConcat = Mid(Result, Len(Delimiter) + 1)
End If
结束功能
答案 0 :(得分:0)
答案是,感谢Mark Fitzgerald,UDF没有任何问题,滞后是由搜索范围引起的。我调整了搜索范围并处理了延迟。