值变化时运行数

时间:2015-09-21 01:59:30

标签: excel vba excel-vba

我有一张包含GIDCASE_IDFUNCTION_NAME

的表格
GID CASE_ID FUNCTION_NAME
01      Fast Cash
01      Fast Cash
01      Fast Cash
01      Fast Cash
01      Fast Cash
01      Fast Cash
01      Fast Cash
01      Fast Cash
01      Withdrawal
01      Withdrawal
01      Withdrawal
01      BALANCE INQUIRY
01      BALANCE INQUIRY
01      BALANCE INQUIRY
01      TRANSFER
01      TRANSFER
01      TRANSFER
01      TRANSFER
01      TRANSFER
01      TRANSFER
01      TRANSFER
01      TRANSFER
01      TRANSFER
01      TRANSFER
01      TRANSFER
01      TRANSFER
02      Fast Cash
02      Fast Cash
02      Withdrawal
02      Withdrawal
02      Withdrawal
02      BALANCE INQUIRY
02      TRANSFER
02      TRANSFER
02      TRANSFER
02      TRANSFER
02      TRANSFER
02      TRANSFER
02      TRANSFER
<{1>} CASE_ID我希望FUNCTION_NAME发生更改时CASE_ID会像这样改变

GID CASE_ID FUNCTION_NAME
01  00100   Fast Cash
01  00101   Fast Cash
01  00102   Fast Cash
01  00103   Fast Cash
01  00104   Fast Cash
01  00105   Fast Cash
01  00106   Fast Cash
01  00107   Fast Cash
01  00200   Withdrawal
01  00201   Withdrawal
01  00202   Withdrawal
01  00300   BALANCE INQUIRY
01  00301   BALANCE INQUIRY
01  00302   BALANCE INQUIRY
01  00400   TRANSFER
01  00401   TRANSFER
01  00402   TRANSFER
01  00403   TRANSFER
01  00404   TRANSFER
01  00405   TRANSFER
01  00406   TRANSFER
01  00407   TRANSFER
01  00408   TRANSFER
01  00409   TRANSFER
01  00410   TRANSFER
01  00411   TRANSFER
02  00100   Fast Cash
02  00101   Fast Cash
02  00200   Withdrawal
02  00201   Withdrawal
02  00202   Withdrawal
02  00300   BALANCE INQUIRY
02  00400   TRANSFER
02  00401   TRANSFER
02  00402   TRANSFER
02  00403   TRANSFER
02  00404   TRANSFER
02  00405   TRANSFER
02  00406   TRANSFER
02  00407   TRANSFER
02  00408   TRANSFER
02  00409   TRANSFER
02  00410   TRANSFER
02  00411   TRANSFER

我尝试使用一些VBA来比较第一个FUNCTION_NAME和第二个FUNCTION_NAME(如果等于+ 1,如果不是那么+ 100。)

1 个答案:

答案 0 :(得分:1)

似乎是一个渐进的IF公式,

=IF(A2<>A1,100,IF(C2<>C1,CEILING(SUM(B1, 1),100),B1+1))

......应该这样做。将其写入B列单元格的块中,类似于

with range("b2:b" & cells(rows.count, 1).end(xlup).row)
    .formula = "=IF(A2<>A1,100,IF(C2<>C1,CEILING(SUM(B1, 1),100),B1+1))"
    .value = .value
end with