hello
previous thread I got help and code from this thread
clear duplicated items in specific columns and arrange below for each item based on column
now I want clear repeated items from column A for first sheet and clear repeated items from column B for second , third sheet
result
if it's not possible to mod the code I accept alternative
previous thread I got help and code from this thread
clear duplicated items in specific columns and arrange below for each item based on column
VBA Code:
Sub Mussa_v2[B]a[/B]()
With Sheets("Sheet2")
'Clear any existing data
.UsedRange.Clear
'Copy the table from Sh1 to Sh2
Sheets("Sheet1").Range("A1").CurrentRegion.Copy .Range("A1")
With .Range("A1").CurrentRegion
'Sort based on column A to get all the groups together
.Sort Key1:=.Columns(1), Order1:=xlAscending, Header:=xlYes
With .Columns(1).Offset(1).Resize(.Rows.Count - 1)
'Look at the column A cells from row 2 down and replace with True if they are the same as the cell above
.Value = Evaluate(Replace(Replace("if(#=%,True,#)", "#", .Address[B](External:=True)[/B]), "%", .Offset(-1).Address[B](External:=True)[/B]))
'Clear contents from all cells that contain True
On Error Resume Next
.SpecialCells(xlConstants, xlLogical).ClearContents
On Error GoTo 0
End With
End With
End With
End Sub
CLEAR.xlsm | ||||||||
---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | |||
1 | DEL NO | BATCH NO | TTL | TT1 | IMPORT | EXPORT | ||
2 | CCD-1 | CC-1 | SS-1 | TRU | 12 | 10 | ||
3 | CCD-1 | CC-1 | SS-1 | LTR | 12 | 5 | ||
4 | CCD-1 | CC-2 | SS-2 | FG | 5 | 5 | ||
5 | CCS-2 | CC-1 | SS-1 | TRR | 10 | 5 | ||
6 | CCS-2 | CC-1 | SS-1 | LTR | 20 | 10 | ||
7 | CSD-1 | CS-1 | LL-1 | RRL | 15 | 5 | ||
8 | CSD-1 | CS-2 | LL-2 | TTY | 10 | 10 | ||
9 | CCD-1 | CS-3 | LL-3 | MMW | 20 | 10 | ||
10 | CCL | CS-4 | LL-4 | NNW | 10 | 10 | ||
11 | CCL | CC-2 | SS-2 | LTR | 21 | 5 | ||
12 | CCM | CC-3 | SS-3 | LTR | 22 | 5 | ||
13 | CSD-1 | CS-1 | LL-1 | RRL | 15 | 5 | ||
sh1 |
CLEAR.xlsm | ||||||
---|---|---|---|---|---|---|
A | B | C | D | |||
1 | ITEM | DEL NO | BATCH NO | IMPORT | ||
2 | 1 | CCS-2 | CC-1 SS-1 TRR | 10 | ||
3 | 2 | CCS-2 | CC-1 SS-1 LTR | 20 | ||
4 | 3 | CCD-1 | CC-1 SS-1 TRU | 12 | ||
5 | 4 | CCD-1 | CC-2 SS-2 FG | 5 | ||
6 | 5 | CSD-1 | CS-1 LL-1 RRL | 15 | ||
7 | 6 | CSD-1 | CS-2 LL-2 TTY | 10 | ||
8 | 7 | CCD-1 | CS-3 LL-3 MMW | 20 | ||
9 | 8 | CCL | CS-4 LL-4 NNW | 10 | ||
10 | 9 | CCL | CC-2 SS-2 LTR | 21 | ||
11 | 10 | CCM | CC-3 SS-3 LTR | 22 | ||
12 | 11 | CSD-1 | CS-1 LL-1 RRL | 15 | ||
msh |
CLEAR.xlsm | ||||||
---|---|---|---|---|---|---|
A | B | C | D | |||
1 | ITEM | DEL NO | BATCH NO | IMPORT | ||
2 | 1 | CCS-2 | CC-1 SS-1 TRR | 10 | ||
3 | 2 | CCD-1 | CC-1 SS-1 TRU | 12 | ||
4 | 3 | CCD-1 | CC-2 SS-2 FG | 5 | ||
5 | 4 | CCD-2 | CC-2 SS-2 FG | 6 | ||
6 | 5 | CCD-2 | CC-2 SS-2 FG | 7 | ||
sdf |
result
CLEAR.xlsm | ||||||||
---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | |||
1 | DEL NO | BATCH NO | TTL | TT1 | IMPORT | EXPORT | ||
2 | CCD-1 | CC-1 | SS-1 | TRU | 12 | 10 | ||
3 | CC-1 | SS-1 | LTR | 12 | 5 | |||
4 | CC-2 | SS-2 | FG | 5 | 5 | |||
5 | CCS-2 | CC-1 | SS-1 | TRR | 10 | 5 | ||
6 | CC-1 | SS-1 | LTR | 20 | 10 | |||
7 | CSD-1 | CS-1 | LL-1 | RRL | 15 | 5 | ||
8 | CS-2 | LL-2 | TTY | 10 | 10 | |||
9 | CS-3 | LL-3 | MMW | 20 | 10 | |||
10 | CCL | CS-4 | LL-4 | NNW | 10 | 10 | ||
11 | CC-2 | SS-2 | LTR | 21 | 5 | |||
12 | CCM | CC-3 | SS-3 | LTR | 22 | 5 | ||
13 | CSD-1 | CS-1 | LL-1 | RRL | 15 | 5 | ||
sh1 |
CLEAR.xlsm | ||||||
---|---|---|---|---|---|---|
A | B | C | D | |||
1 | ITEM | DEL NO | BATCH NO | IMPORT | ||
2 | 1 | CCS-2 | CC-1 SS-1 TRR | 10 | ||
3 | 2 | CC-1 SS-1 LTR | 20 | |||
4 | 3 | CCD-1 | CC-1 SS-1 TRU | 12 | ||
5 | 4 | CC-2 SS-2 FG | 5 | |||
6 | 5 | CSD-1 | CS-1 LL-1 RRL | 15 | ||
7 | 6 | CS-2 LL-2 TTY | 10 | |||
8 | 7 | CS-3 LL-3 MMW | 20 | |||
9 | 8 | CCL | CS-4 LL-4 NNW | 10 | ||
10 | 9 | CC-2 SS-2 LTR | 21 | |||
11 | 10 | CCM | CC-3 SS-3 LTR | 22 | ||
12 | 11 | CSD-1 | CS-1 LL-1 RRL | 15 | ||
msh |
CLEAR.xlsm | ||||||
---|---|---|---|---|---|---|
A | B | C | D | |||
1 | ITEM | DEL NO | BATCH NO | IMPORT | ||
2 | 1 | CCS-2 | CC-1 SS-1 TRR | 10 | ||
3 | 2 | CCD-1 | CC-1 SS-1 TRU | 12 | ||
4 | 3 | CC-2 SS-2 FG | 5 | |||
5 | 4 | CCD-2 | CC-2 SS-2 FG | 6 | ||
6 | 5 | CC-2 SS-2 FG | 7 | |||
sdf |
if it's not possible to mod the code I accept alternative