Nancy Therrien
asked on
For Next Loop, not working
Good Afternoon,
I'm trying to compare data from an Excel Sheets, I have to compare rows with each other.
My data is like :
1 aaaaaaa 19.5 15 louis
2 aaaaaaa 19.5 louis
2 aaaaaaa 19.5 15 a louis
3 aaaaaaa 19.5 louis
I need to verify that all columns for each row are equal to the rows above. Here is my code and it is not working.
Can you please help me.
If I don't take care of the 3rd columns it was doing good.
It always give me a NExt error or else without if
Thanks in advance.
I'm trying to compare data from an Excel Sheets, I have to compare rows with each other.
My data is like :
1 aaaaaaa 19.5 15 louis
2 aaaaaaa 19.5 louis
2 aaaaaaa 19.5 15 a louis
3 aaaaaaa 19.5 louis
I need to verify that all columns for each row are equal to the rows above. Here is my code and it is not working.
Can you please help me.
If I don't take care of the 3rd columns it was doing good.
It always give me a NExt error or else without if
Thanks in advance.
dim i as Integer ' row 6 to end
Dim j As Integer ' columns F to U
For i = lastrow To 6 Step -1
If Cells(i, 2) = Cells(i - 1, 2) And Cells(i, 6) = Cells(i - 1, 6) Then
If Cells(i - 1, 23) = Cells(i, 23) Then
For j = 6 To 22 Step 1
If Cells(i, j) = Cells(i - 1, j) Then
' Next j
Cells(i - 1, 1) = Cells(i - 1, 1) + Cells(i, 1)
Rows(i).Delete Shift:=xlUp
Else
End If
Else ' put color 'met la ligne en couleur
Rows(i).Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 65535
.TintAndShade = 0
.PatternTintAndShade = 0
End With
End If
Next i
please post a representative sample workbook
ASKER
Is your posted code in one of the modules in the workbook you posted?
ASKER
Hello, In module TestNancy, and it is called Test1()
Thanks
Thanks
I see a Test1() in Module2, but not in TestNancy
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hello,
Thanks for helping, it is working great now.
I really appreciated your help.
for the color thing it was just to mark those which are almost identical, the one which the difference is in the S-T or Laser columns.
I will take that off.
Thanks again.
Nancy
Thanks for helping, it is working great now.
I really appreciated your help.
for the color thing it was just to mark those which are almost identical, the one which the difference is in the S-T or Laser columns.
I will take that off.
Thanks again.
Nancy
ASKER
Good Morning,
Just for my personnal information and formation.
How this line is working : boolCellDataIsSame = True
is that true by default ?
Thanks
Nancy
Just for my personnal information and formation.
How this line is working : boolCellDataIsSame = True
is that true by default ?
Thanks
Nancy
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
This will compile but I can't tell if it'll do what you want without sample before/after data.
Open in new window