im试图创建一个具有特定对象类型和数据集中出现次数的表。我尝试创建2组数组以首先为订单类型建立索引,如果订单类型已经存在于第一个数组中,则将一个1添加到一个采行数组中。我遇到的问题是每一行都被索引为其自己的类型,并返回1的出现。这是代码im使用
Sub Comparison()
Dim Sheet As Worksheet
Dim Book As Workbook
Set Book = Excel.ActiveWorkbook
Set Sheet = Book.Sheets("Sheet1")
Dim i As Integer
Dim c As Integer 'counter for number of items needed in array
Dim arr() As String 'type of order
Dim occ() As Long
For i = 2 To 31
If Sheet.Cells(i, 3).Value <> "" And Sheet.Cells(i, 2).Value <> "" Then
If isThere(Sheet.Cells(i, 2).Value, arr, c) = -1 Then
c = c + 1
ReDim Preserve arr(1 To c)
arr(c) = Sheet.Cells(i, 2).Value
ReDim Preserve occ(1 To c)
occ(c) = 1
Else
occ(isThere(Sheet.Cells(i, 2).Value, arr, c)) = occ(isThere(Sheet.Cells(i, 2).Value, arr, c)) + 1
End If
End If
Next i
结束子
Public Function isThere(search As String, arra As Variant, x As Integer) As Long
Dim q
isThere = -1
For q = 1 To x
If StrComp(search, arra(q), vbTextCompare) = 0 Then
isThere = q
Exit For
End If
Next q
End Function
答案 0 :(得分:1)
您可以使用一个字典来代替使用两个数组。
字典具有唯一键和成对的项值,键将是您的单元格值,项将是出现的项。
html *:not(.myclass *) {
box-shadow: none !important;
border: none !important;
color: white;
}