Hello to you all (Bonjour from Montreal),
I have a macro which creates a table from an other tab. Once this new table is created I can end up with several lines having the same content.
A1 A2
---------------
cat what ever
dog what ever
rabit what ever
elephant what ever
rabit what ever
In this case I have two lines with the name "rabit".
I would like my macro to delete the second rabit line. The table could end up to have several "cat", "dog", etc. But I want to end up with only one line of "cat", One line of "dog" and so on.
Thank you guys!
Here is my code
Sub Prepare()
Application.ScreenUpdating = False
Sheets("DASH_BOARD_DATA").Select
Range("D2:J13").Select
Selection.ClearContents
p = Sheets("PRIORITY").Cells(1, 1).CurrentRegion.Rows.Count
Set PREP1 = Sheets("DASH_BOARD_DATA").Cells(2, 4).CurrentRegion
x = 2
For i = 2 To p
If Sheets("PRIORITY").Cells(i, 6).Value = 1 _
Or Sheets("PRIORITY").Cells(i, 6).Value = 2 Then
If Sheets("PRIORITY").Cells(i, 17).Value = "X" _
And Sheets("PRIORITY").Cells(i, 18).Value = "" _
And Sheets("PRIORITY").Cells(i, 19).Value = "" _
And Sheets("PRIORITY").Cells(i, 20).Value = "" Then
PREP1.Cells(x, 1) = Sheets("PRIORITY").Cells(i, 7).Value
PREP1.Cells(x, 2) = Sheets("PRIORITY").Cells(i, 8).Value
PREP1.Cells(x, 3) = Sheets("PRIORITY").Cells(i, 21).Value
PREP1.Cells(x, 4) = Sheets("PRIORITY").Cells(i, 22).Value
PREP1.Cells(x, 5) = Sheets("PRIORITY").Cells(i, 25).Value
PREP1.Cells(x, 6) = Sheets("PRIORITY").Cells(i, 26).Value
PREP1.Cells(x, 7) = Sheets("PRIORITY").Cells(i, 29).Value
PREP1.Cells(x, 8) = Sheets("PRIORITY").Cells(i, 6).Value
PREP1.Cells(x, 9) = Sheets("PRIORITY").Cells(i, 13).Value
x = x + 1
End If
End If
Next i
Application.ScreenUpdating = True
End Sub
I have a macro which creates a table from an other tab. Once this new table is created I can end up with several lines having the same content.
A1 A2
---------------
cat what ever
dog what ever
rabit what ever
elephant what ever
rabit what ever
In this case I have two lines with the name "rabit".
I would like my macro to delete the second rabit line. The table could end up to have several "cat", "dog", etc. But I want to end up with only one line of "cat", One line of "dog" and so on.
Thank you guys!
Here is my code
Sub Prepare()
Application.ScreenUpdating = False
Sheets("DASH_BOARD_DATA").Select
Range("D2:J13").Select
Selection.ClearContents
p = Sheets("PRIORITY").Cells(1, 1).CurrentRegion.Rows.Count
Set PREP1 = Sheets("DASH_BOARD_DATA").Cells(2, 4).CurrentRegion
x = 2
For i = 2 To p
If Sheets("PRIORITY").Cells(i, 6).Value = 1 _
Or Sheets("PRIORITY").Cells(i, 6).Value = 2 Then
If Sheets("PRIORITY").Cells(i, 17).Value = "X" _
And Sheets("PRIORITY").Cells(i, 18).Value = "" _
And Sheets("PRIORITY").Cells(i, 19).Value = "" _
And Sheets("PRIORITY").Cells(i, 20).Value = "" Then
PREP1.Cells(x, 1) = Sheets("PRIORITY").Cells(i, 7).Value
PREP1.Cells(x, 2) = Sheets("PRIORITY").Cells(i, 8).Value
PREP1.Cells(x, 3) = Sheets("PRIORITY").Cells(i, 21).Value
PREP1.Cells(x, 4) = Sheets("PRIORITY").Cells(i, 22).Value
PREP1.Cells(x, 5) = Sheets("PRIORITY").Cells(i, 25).Value
PREP1.Cells(x, 6) = Sheets("PRIORITY").Cells(i, 26).Value
PREP1.Cells(x, 7) = Sheets("PRIORITY").Cells(i, 29).Value
PREP1.Cells(x, 8) = Sheets("PRIORITY").Cells(i, 6).Value
PREP1.Cells(x, 9) = Sheets("PRIORITY").Cells(i, 13).Value
x = x + 1
End If
End If
Next i
Application.ScreenUpdating = True
End Sub