-1
好吧所以我一直在想出一些东西来运行这个。VBA循环函数基于列表中的值
基本上我需要循环表2中列A的值,对于需要在表1中找到它的每个值,然后根据H列中的标识符(4个变量),为单元格添加一个计数,如果它符合一个标准,那么它可能需要检查K列来知道哪个值。
例如:
开始在第2页第2行,其具有数“123456789”,其中具有在列B(因此B *找到)号码“123456789”片1查找行 如果H *有一个值,那么它需要在表格2的正确列中为该数字添加一个值到记录器。如果H * =某个标准,那么它需要检查列K中的标准,然后将该值添加到正确的列。 我完全失去了如何设置。 任何帮助将是惊人的,非常感谢
乔恩
代码现在如下: 子Status_Track()
Dim a As Long 'topic number
Dim Z As Integer
Dim R As Integer
Dim i As Integer
Dim S As Integer
Dim D As Integer
Worksheets("RAW").Activate
R = Cells(Rows.Count, 2).End(xlUp).Row
C = Cells(1, Columns.Count).End(xlToLeft).Column
Z = 0
i = 2
Do Until i > R
'ident
If Cells(i, 2) = Worksheets("Data").Cells(i, 2) And (Cells(i, 13) = "ERKA")Then
Z = Cells(i, 6) + 1
Worksheets("RAW").Cells(i, 6).Value = Z
Else
If Cells(i, 2) = Worksheets("Data").Cells(i, 2) And (Cells(i, 13) = "INBA") Then
'Inba
Z = Cells(i, 7) + 1
Worksheets("RAW").Cells(i, 7).Value = Z
Else
If Cells(i, 2) = Worksheets("Data").Cells(i, 2) And (Cells(i, 13) = "ABGE") Then
'Abge
Z = Cells(i, 8) + 1
Worksheets("RAW").Cells(i, 8).Value = Z
Else
If Cells(i, 2) = Worksheets("Data").Cells(i, 2) And (Cells(i, 13) = "GELO") Then
'Gelo
Z = Cells(i, 5) + 1
Worksheets("RAW").Cells(i, 5).Value = Z
Else
If Cells(i, 2) = Worksheets("Data").Cells(i, 2) And (Cells(i, 13) = "UEBE") And (Cells(i, 11) = 0) Then
'UEBE
Z = Cells(i, 10) + 1
Worksheets("Data").Cells(i, 9).Value = Z
Else
If Cells(i, 11) = 1 And (Cells(i, 28) = "<1") Then
'1
Z = Cells(i, 10) + 1
Worksheets("Data").Cells(i, 10).Value = Z
Else
If Cells(i, 11) = 1 And (Cells(i, 28) = "6") Then
'6
Z = Cells(i, 10) + 1
Worksheets("Data").Cells(i, 11).Value = Z
Else
If Cells(i, 11) = 1 And (Cells(i, 28) = "9") Then
'9
Z = Cells(i, 10) + 1
Worksheets("Data").Cells(i, 12).Value = Z
Else
If Cells(i, 11) = 1 And (Cells(i, 28) = "10") Then
'10
Z = Cells(i, 10) + 1
Worksheets("Data").Cells(i, 13).Value = Z
Else
If Cells(i, 11) = 1 And (Cells(i, 28) = "15") Then
'15
Z = Cells(i, 10) + 1
Worksheets("Data").Cells(i, 14).Value = Z
Else
If Cells(i, 11) = 1 And (Cells(i, 28) = "30") Then
'30
Z = Cells(i, 10) + 1
Worksheets("Data").Cells(i, 15).Value = Z
Else
If Cells(i, 11) = 1 And (Cells(i, 28) = "50") Then
'50
Z = Cells(i, 10) + 1
Worksheets("Data").Cells(i, 16).Value = Z
Else
If Cells(i, 11) = 1 And (Cells(i, 28) = "60") Then
'60
Z = Cells(i, 10) + 1
Worksheets("Data").Cells(i, 17).Value = Z
Else
If Cells(i, 11) = 1 And (Cells(i, 28) = "70") Then
'70
Z = Cells(i, 10) + 1
Worksheets("Data").Cells(i, 18).Value = Z
Else
If Cells(i, 11) = 1 And (Cells(i, 28) = "80") Then
'80
Z = Cells(i, 10) + 1
Worksheets("Data").Cells(i, 19).Value = Z
Else
If Cells(i, 11) = 1 And (Cells(i, 28) = "90") Then
'90
Z = Cells(i, 10) + 1
Worksheets("Data").Cells(i, 20).Value = Z
Else
If Cells(i, 11) = 1 And (Cells(i, 28) = "97") Then
'97
Z = Cells(i, 10) + 1
Worksheets("Data").Cells(i, 21).Value = Z
Else
If Cells(i, 11) = 1 And (Cells(i, 28) = "100") Then
'100
Z = Cells(i, 10) + 1
Worksheets("Data").Cells(i, 22).Value = Z
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End Sub
谢谢, 我似乎写了一个代码,但我不断收到错误maeesages。 我也无法上传,因为它太长了 –
你得到了什么样的错误? –
错误溢出。 上面的代码尽我所能,但它似乎并没有工作。 –