Hi,
I'm struggling to write a multidimensional array.
Could you please help?
Here is what I’m trying to do...
I have an excel sheet with the following data
Row 1 Column P 10,500
Row 2 Column P --------
Row 3 Column P 10,500
Row 4 Column P 6,000
Row 5 Column P --------
Row 6 Column P 6,000
Row 7 Column P 10,500
I wrote a loop to remove dupes but it only removes a dupe if the next cell is the same as the previous cell.
I would like it to ignore the "--------" and remove any rows that have a repeat value in any cell in column P.
So the output would look like this
Row 1 Column P 10,500
Row 2 Column P --------
Row 3 Column P 6,000
Row 4 Column P --------
Thank you in advance for your help.
Sub RemoveDupes()
'
'
Dim RowInfo() As Variant
Dim counter As Long
Dim r As Range
Dim n As Long
Sheets("Sheet1").Select ' selects the sheet
Range("P1").Select ' select a column
Selection.End(xlDown).Select
Set r = Range("P1:" & Selection.Address) 'This is where you set the column to sort on
For n = 1 To r.Rows.Count
If r.Cells(n, 1) <> r.Cells(n + 1, 1) Then '(N is the row and ,1 is the column)
'This will check the cells against each other
ReDim Preserve RowInfo(counter) 'Make RowInfo dynamic.
RowInfo(counter) = Mid(r.Cells(n, 1), 1, 7)
counter = counter + 1 ' Set Index for 2nd loop
End If
Next n
'========================================================================
Sheets("Sheet1").Range("A1").Resize(counter) = Application.Transpose(RowInfo) ' places results on a separate spread sheet
End Sub
Bookmarks