|
返回未出数据两种公式输入.zip
(25.19 KB, 下载次数: 7)
自定义函数WCSJ需要在模块1和Thisworkbook两个地方分别输入代码,使用起来很不方便。恳请老师们编写一个只需粘贴进任意一个模块里的代码,不胜感谢之至!
一.模块1 代码
Option Explicit
Public list
Function WCSJ(r1, r2, Optional x = -1)
Dim ar(1), i, j, k, Res
ar(0) = r1: ar(1) = r2
For j = 0 To 1
For i = LBound(ar(j)) To UBound(ar(j))
If j Then
If list.Contains(ar(j)(i, 1)) Then list.Remove (ar(j)(i, 1))
Else
If ar(j)(i, 1) <> "" Then list.Add ar(j)(i, 1)
End If
Next
Next
Res = list.ToArray
j = UBound(Res) + 1
If x = -1 Then
ReDim Preserve Res(0 To j + 88 + Selection.Count)
For i = j To j + 88 + Selection.Count
Res(i) = ""
Next
WCSJ = Application.Transpose(Res)
Else
If x > j Then
WCSJ = ""
Else
WCSJ = Res(x - 1)
End If
End If
list.Clear
End Function
二.需要粘贴进 Thisworkbook 的代码
'返回未出现数据 WCSJ
Option Explicit
Private Sub Workbook_Open()
Set list = CreateObject("System.Collections.ArrayList")
End Sub
|
评分
-
1
查看全部评分
-
|