Dear All master,
I want if I make changes in the "master" sheet it automatically changes in the "trans" sheet.
I want a fast code because there are thousands of records in the "trans" sheet.
below is the vba event code in the "trans" sheet
I want if I make changes in the "master" sheet it automatically changes in the "trans" sheet.
I want a fast code because there are thousands of records in the "trans" sheet.
vba vlookup Change Event in array and dictionary .xlsm | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | I | J | |||
1 | Supplier Name | CODE | NEW CODE | COMBINE | ITEM DESC | NEW PRICE | Isi | UNIT IN ACTUAL | Price | UNIT IN KONVERSI | ||
2 | STOCK OPNAME | BBK5801 | 04-00100101 | AQUA1000 | 18,000 | 1 | yard | 20,000 | mtr | |||
3 | STOCK OPNAME | BBK5802 | 04-00100101 | AQUA200 | 18,001 | yard | 20,001 | mtr | ||||
4 | STOCK OPNAME | BBK5803 | 04-00100101 | AQUA3 | 18,002 | yard | 20,002 | mtr | ||||
5 | STOCK OPNAME | BBK5804 | 04-00100101 | AQUA4 | 18,003 | yard | 20,003 | mtr | ||||
6 | STOCK OPNAME | BBK5805 | 04-00100101 | AQUA5 | 18,004 | yard | 20,004 | mtr | ||||
7 | STOCK OPNAME | BBK5806 | 04-00100101 | AQUA6 | 18,004 | yard | 20,004 | mtr | ||||
8 | STOCK OPNAME | BBK5807 | 04-00100101 | AQUA7 | 18,004 | yard | 20,004 | mtr | ||||
9 | STOCK OPNAME | BBK5808 | 04-00100101 | AQUA8 | 18,004 | yard | 20,004 | mtr | ||||
10 | STOCK OPNAME | BBK5809 | 04-00100101 | AQUA9 | 18,004 | yard | 20,004 | mtr | ||||
11 | STOCK OPNAME | BBK5810 | 04-00100101 | AQUA10 | 18,004 | yard | 20,004 | mtr | ||||
MASTER |
Cell Formulas | ||
---|---|---|
Range | Formula | |
I2:I11 | I2 | =MASTER!$F$2:$F$11/0.9 |
vba vlookup Change Event in array and dictionary .xlsm | |||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | |||
1 | KEY | COUNT | ADDRESS1 | ADDRESS2 | CITY | NOTE | RESULT | RECEIVE ITEM NO | SUPPLIER NAME | DATE IN | CODE | NEW CODE | ITEM DESC | QTY IN ACTUAL | UNIT IN ACTUAL | QTY IN KONVERSI | UNIT IN KONVERSI | NEW PRICE | |||
2 | 0 | ASTOCK OPNAME | 1 | GUDANG HOLIS | GUDANG HOLIS | Bandung | 74 | NOT SAME | 1000 | STOCK OPNAME | 19/05/2016 | BBK5801 | 0116002001 | AQUA1000 | 74 | yard | 66.60 | mtr | 18,000 | ||
3 | 0 | ASTOCK OPNAME | 1 | GUDANG HOLIS | GUDANG HOLIS | Bandung | 74 | NOT SAME | 1002 | STOCK OPNAME | 20/05/2016 | BBK5802 | 0116002001 | AQUA200 | 74 | yard | 66.60 | mtr | 18,001 | ||
4 | 0 | ASTOCK OPNAME | 1 | GUDANG HOLIS | GUDANG HOLIS | Bandung | 74 | NOT SAME | 1002 | STOCK OPNAME | 20/05/2016 | BBK5803 | 0116002001 | AQUA3 | 50 | yard | 45.00 | mtr | 18,002 | ||
5 | 0 | ASTOCK OPNAME | 1 | GUDANG HOLIS | GUDANG HOLIS | Bandung | 74 | NOT SAME | 1002 | STOCK OPNAME | 20/05/2016 | BBK5804 | 0116002001 | AQUA4 | 50 | yard | 45.00 | mtr | 18,003 | ||
6 | 0 | ASTOCK OPNAME | 1 | GUDANG HOLIS | GUDANG HOLIS | Bandung | 74 | NOT SAME | 1002 | STOCK OPNAME | 20/05/2016 | BBK5805 | 0116002001 | AQUA5 | 50 | yard | 45.00 | mtr | 18,004 | ||
7 | 0 | ASTOCK OPNAME | 1 | GUDANG HOLIS | GUDANG HOLIS | Bandung | 74 | NOT SAME | 1002 | STOCK OPNAME | 20/05/2016 | BBK5806 | 0116002001 | AQUA6 | 50 | yard | 45.00 | mtr | 18,004 | ||
8 | 0 | ASTOCK OPNAME | 1 | GUDANG HOLIS | GUDANG HOLIS | Bandung | 74 | NOT SAME | 1002 | STOCK OPNAME | 20/05/2016 | BBK5807 | 0116002001 | AQUA7 | 50 | yard | 45.00 | mtr | 18,004 | ||
TRANS |
Cell Formulas | ||
---|---|---|
Range | Formula | |
Q2:Q8 | Q2 | =O2*0.9 |
below is the vba event code in the "trans" sheet
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range, c As Range, m, wsM As Worksheet, arr
Set rng = Application.Intersect(Target, Me.Range("L:L"))
If rng Is Nothing Then Exit Sub
Set wsM = ThisWorkbook.Worksheets("MASTER")
On Error GoTo bm_Safe_Exit
Application.EnableEvents = False
Application.ScreenUpdating = False 'improve performance...
Application.Calculation = xlCalculationManual
For Each c In rng.Cells 'process all changed cells in ColB
v = c.Value
If Len(v) > 0 Then
m = Application.Match(c.Value, wsM.Range("B:B"), 0) 'match much faster than Find()
If Not IsError(m) Then
arr = wsM.Cells(m, "E").Resize(1, 6) 'one read
c.Offset(0, 2).Value = arr(1, 1)
c.Offset(0, 4).Value = arr(1, 4)
c.Offset(0, 6).Resize(1, 2).Value = Array(arr(1, 6), arr(1, 2))
End If
Else
c.EntireRow.Range("N1,P1,R1:S1").ClearContents 'clear cells if no code
End If
Next c
bm_Safe_Exit:
Application.EnableEvents = True 'be sure to re-enable events
Application.Calculation = xlCalculationAutomatic 'reset calculation
End Sub