waldermort
Mar 9th, 2006, 08:30 AM
I have have finally got my code up and running for the most part. I am comparing the values of cells, which contain strings. My function works to a degree but it is case dependant. How do you implement a non-case sensetive comparison of two strings in vb?
Sub RemoveDuplicates()
Dim iListCount As Integer
Dim iCtr As Integer
iListCount = xlSheet.usedrange.Rows.Count
xlSheet.Range("A1").Activate
Do Until xlApp.activecell = ""
For iCtr = 1 To iListCount
If xlApp.activecell.Row <> xlSheet.cells(iCtr, 1).Row Then
If xlApp.activecell.Value = xlSheet.cells(iCtr, 1).Value Then
' a duplicate name was found
If xlApp.activecell.offset(0, 1).Value = xlSheet.cells(iCtr, 2).Value Then
If xlApp.activecell.offset(0, 2).Value = xlSheet.cells(iCtr, 3).Value Then
' a duplicate student was found
xlSheet.cells(iCtr, 1).Delete shift:=-4162
iCtr = iCtr + 1
End If
End If
End If
End If
Next iCtr
xlApp.activecell.offset(1, 0).Select
Loop
End Sub
In the above code I am refering to the cells by value rather than by text, this is because I'm not sure how to deal with Unicode in vb. In C its a nightmare sometimes trying to distinguish between the various encodings.
Sub RemoveDuplicates()
Dim iListCount As Integer
Dim iCtr As Integer
iListCount = xlSheet.usedrange.Rows.Count
xlSheet.Range("A1").Activate
Do Until xlApp.activecell = ""
For iCtr = 1 To iListCount
If xlApp.activecell.Row <> xlSheet.cells(iCtr, 1).Row Then
If xlApp.activecell.Value = xlSheet.cells(iCtr, 1).Value Then
' a duplicate name was found
If xlApp.activecell.offset(0, 1).Value = xlSheet.cells(iCtr, 2).Value Then
If xlApp.activecell.offset(0, 2).Value = xlSheet.cells(iCtr, 3).Value Then
' a duplicate student was found
xlSheet.cells(iCtr, 1).Delete shift:=-4162
iCtr = iCtr + 1
End If
End If
End If
End If
Next iCtr
xlApp.activecell.offset(1, 0).Select
Loop
End Sub
In the above code I am refering to the cells by value rather than by text, this is because I'm not sure how to deal with Unicode in vb. In C its a nightmare sometimes trying to distinguish between the various encodings.