Hi,
I'm struggling to write a multidimensional array.
Could you please help?
Here is what I’m trying to do...
With alot of help I was able to write a OBject dictionary in a loop that removes dupes.
During this build I did not take into account that I needed to restart the loop whenever the cell in column L is not the same as the next cell down.
Here is an example of my input Data:
Column L Column P
Row 1 9 10,500
Row 2 9 10,500
Row 3 9 6,000
Row 4 8 --------
Row 5 8 6,000
Row 6 8 6,000
Row 7 8 5,250
Row 8 8 --------
Row 9 7 6,000
Row 10 7 10,500
I would like the output to look like this:
Column L Column P
Row 1 9 10,500
Row 2 9 6,000
Row 3 8 --------
Row 4 8 6,000
Row 5 8 5,250
Row 6 8 --------
Row 7 7 6,000
Row 8 7 10,500
Rows 2 and 6 were deleted because they were dupes in the same group in column L
Thank you in advance for your help.
I'm struggling to write a multidimensional array.
Could you please help?
Here is what I’m trying to do...
With alot of help I was able to write a OBject dictionary in a loop that removes dupes.
During this build I did not take into account that I needed to restart the loop whenever the cell in column L is not the same as the next cell down.
Here is an example of my input Data:
Column L Column P
Row 1 9 10,500
Row 2 9 10,500
Row 3 9 6,000
Row 4 8 --------
Row 5 8 6,000
Row 6 8 6,000
Row 7 8 5,250
Row 8 8 --------
Row 9 7 6,000
Row 10 7 10,500
I would like the output to look like this:
Column L Column P
Row 1 9 10,500
Row 2 9 6,000
Row 3 8 --------
Row 4 8 6,000
Row 5 8 5,250
Row 6 8 --------
Row 7 7 6,000
Row 8 7 10,500
Rows 2 and 6 were deleted because they were dupes in the same group in column L
Thank you in advance for your help.
Code:
Sub RemoveDupes()
'
'
Dim ObjDic As Object
Dim RowInfo() As Variant
Dim counter As Long
Dim r As Range: Dim F As Range
Dim n As Long
Dim LastRow As Long
Dim WkRg As Range
Dim x As Range
Dim z As Long
If ActiveSheet.Select <> "Sheet1" Then
Sheets("Finishing Schedule Report").Select ' selects the sheet
End If
Range("L1").Select ' select a column
Set ObjDic = CreateObject("Scripting.Dictionary")
With Sheets("Finishing Schedule Report")
LastRow = .Range("P" & Rows.Count).End(xlUp).Row
Set WkRg = .Cells(LastRow + 1, "P")
Set r = .Range("P1:P" & LastRow) ' This is where you set the column to sort on
Set x = .Range("L1:" & Selection.Address) ' number location ' <---- does not work
ReDim RowInfo(1 To LastRow) ' <---- does not work
For z = 1 To x.Rows.Count ' <---- does not work
If x.Cells(z, 1) <> x.Cells(z + 1, 1) Then ' <---- does not work
For Each F In r
If (F.Value = "--------") Then
n = n + 1: RowInfo(n) = F.Value
Else
If Not (ObjDic.exists(F.Value)) Then
n = n + 1: RowInfo(n) = F.Value: ObjDic(F.Value) = Empty
Else
Set WkRg = Union(WkRg, F)
End If
End If
Next F
End If ' <---- does not work
Next z ' <---- does not work
'========================================================================
WkRg.EntireRow.Delete
End With
End Sub