VBA with multiple while conditions -
i need modify code have correct values in column j
.
colored better understanding, rows have same values columns a d
in column j
want have correct values follows:
- if row 6 = row 7
j6 = 2
- if row 8 = row 9 = row 10
j8 = 3
- , on
my code not enough, because don't want have red values
in column j
dim tw worksheet: set tw = thisworkbook.worksheets("stack") dim row integer row = tw.range("b" & rows.count).end(xlup).row lin = 2 until lin = row + 1 nr = 1 while (tw.cells(lin, 1) = tw.cells(lin + nr, 1) , tw.cells(lin, 2) = tw.cells(lin + nr, 2) , tw.cells(lin, 3) = tw.cells(lin + nr, 3) , tw.cells(lin, 4) = tw.cells(lin + nr, 4)) nr = nr + 1 wend if nr = 1 else tw.cells(lin, 10) = nr end if lin = lin + 1 loop
Comments
Post a Comment