Hi
I want matching column BATCH NO(C) for sheet DATA with the same column for FIRST. so every item is missed in column B in FIRST should fill based on is existed in column B for sheet DATA after match items in column C between two sheets .
RESULT IN SHEET FIRST
this is what I have , but gives error subscript out of range
hope somebody help
I want matching column BATCH NO(C) for sheet DATA with the same column for FIRST. so every item is missed in column B in FIRST should fill based on is existed in column B for sheet DATA after match items in column C between two sheets .
MATCH.xlsm | ||||||||
---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | |||
1 | ITEM | DEL NO | BATCH NO | ITEM | TT1 | QTY | ||
2 | 1 | CC-mm/17 | LL-1 | RRL | 10 | |||
3 | 2 | CC-mm/18 | LL-2 | TTY | 2 | |||
4 | 3 | CC-mm/19 | LL-3 | MMW | 5 | |||
5 | 4 | CC-mm/20 | LL-4 | NNW | 1 | |||
6 | 5 | CC-mm/21 | LL-5 | TRU | 10 | |||
7 | 6 | CC-mm/13 | SS-1 | LTR | 10 | |||
8 | 7 | CC-mm/14 | SS-2 | FG | 20 | |||
9 | 8 | CC-mm/15 | SS-1 | TRR | 20 | |||
10 | 9 | CC-mm/161 | cv3 | MNT | 20 | |||
FIRST |
MATCH.xlsm | |||||||
---|---|---|---|---|---|---|---|
A | B | C | D | E | |||
1 | ITEM | DEL NO | BATCH NO | ITEM | TT1 | ||
2 | 1 | CC-1 | CC-mm/12 | SS-1 | TRU | ||
3 | 2 | CC-2 | CC-mm/13 | SS-1 | LTR | ||
4 | 3 | CC-3 | CC-mm/14 | SS-2 | FG | ||
5 | 4 | CC-4 | CC-mm/15 | SS-1 | TRR | ||
6 | 5 | CC-5 | CC-mm/16 | SS-1 | LTR | ||
7 | 6 | CC-6 | CC-mm/17 | LL-1 | RRL | ||
8 | 7 | CC-7 | CC-mm/18 | LL-2 | TTY | ||
9 | 8 | CC-8 | CC-mm/19 | LL-3 | MMW | ||
10 | 9 | CC-9 | CC-mm/20 | LL-4 | NNW | ||
11 | 10 | CC-10 | CC-mm/21 | LL-5 | TRU | ||
DATA |
RESULT IN SHEET FIRST
MATCH.xlsm | ||||||||
---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | |||
1 | ITEM | DEL NO | BATCH NO | ITEM | TT1 | QTY | ||
2 | 1 | CC-6 | CC-mm/17 | LL-1 | RRL | 10 | ||
3 | 2 | CC-7 | CC-mm/18 | LL-2 | TTY | 2 | ||
4 | 3 | CC-8 | CC-mm/19 | LL-3 | MMW | 5 | ||
5 | 4 | CC-9 | CC-mm/20 | LL-4 | NNW | 1 | ||
6 | 5 | CC-10 | CC-mm/21 | LL-5 | TRU | 10 | ||
7 | 6 | CC-2 | CC-mm/13 | SS-1 | LTR | 10 | ||
8 | 7 | CC-3 | CC-mm/14 | SS-2 | FG | 20 | ||
9 | 8 | CC-4 | CC-mm/15 | SS-1 | TRR | 20 | ||
10 | 9 | CC-mm/161 | cv3 | MNT | 20 | |||
FIRST |
this is what I have , but gives error subscript out of range
VBA Code:
c(n, 2) = a(i, 2)
VBA Code:
Sub test2()
Dim a, b, c, txt As String, temp As String
Dim i As Long, ii As Long, n As Long
a = Sheets("data").Cells(1).CurrentRegion.Value
b = Sheets("first").Cells(1).CurrentRegion.Value
c = b: n = 1
For i = 2 To UBound(a, 1)
If a(i, 2) = "" Then a(i, 2) = a(i - 2, 1)
txt = a(i, 3)
If txt = a(i, 3) Then
n = n + 1
If temp <> a(i, 2) Then c(n, 2) = a(i, 2): temp = a(i, 2)
End If
Next
Sheets("first").Cells(1).CurrentRegion.Value = c
End Sub