Hi All,
I have a problem with loop in my code:
the problem is if I have two rows with ABC next to eachother, it copies the same values[ (i,19) (i,27)]as for first abc, even if the second one has them different.
The table looks like this:
220
[tr]
[td]ABC[/td]
[td]621[/td]
[/tr]
I have 3 row with ABC but it copies always "123", I tried to replace If with Select case, but no luck..it still copie values for 1st row, not second. ;/
I have a problem with loop in my code:
Code:
Sub test2()
Dim i As Integer
i = 1
Sheets("Sheet1").Activate
For Each row In Range("g2").End(xlDown)
If Cells(i, 13).Value = "ABC" Then
Range(Cells(i, 19), Cells(i, 27)).Copy
Sheets("ABC").Activate
Range("c2:k2").PasteSpecial Paste:=xlPasteValues
Sheets("ABC").Range("F:F").Calculate
ElseIf Cells(i, 13).Value = "123" Then
Range(Cells(i, 19), Cells(i, 27)).Copy
Sheets("123").Activate
Range("c2:k2").PasteSpecial Paste:=xlPasteValues
Sheets("123").Range("F:F").Calculate
Next
end if
End Sub
the problem is if I have two rows with ABC next to eachother, it copies the same values[ (i,19) (i,27)]as for first abc, even if the second one has them different.
The table looks like this:
ABC | 123 |
ABC | 546 |
[tr]
[td]ABC[/td]
[td]621[/td]
[/tr]
I have 3 row with ABC but it copies always "123", I tried to replace If with Select case, but no luck..it still copie values for 1st row, not second. ;/
Last edited: