Kindly help to update to this fill

lathish

New Member
Joined
Feb 10, 2018
Messages
15
HEY GUYS PLEASE HELP


THERE 3 WORKSHEETS

SHEET 1

PRODUCTMRPQTY
AA1202
BB1213
CC1224
DD1235
EE1246
FF1257
GG1268
HH1279
II12810

<colgroup><col><col span="2"></colgroup><tbody>
</tbody>



<colgroup><col><col span="3"></colgroup><tbody>
</tbody>

SHEET 2

PRODUCTCODE
AA300
BB300
CC300
DD200
EE200
FF300
GG500
HH500
II500
JJ300
KK500
LL500
MM200
NN200

<colgroup><col width="64" span="2" style="width:48pt"> </colgroup><tbody>
</tbody>

SHEET 3

PRODUCT CODE MRPQTY
AA
CC
DD
II

<colgroup><col width="64" span="4" style="width:48pt"> </colgroup><tbody>
</tbody>


SHEET 3 WILL BE MY RESULT SHEET IN WHICH I HAVE TO FIND CODE FROM SHEET LATER ONCE CODE IS UPDATED THEN IN SHEET 3 REMAINING DATA SHOULD BE PASTE TO SHEET 3 FROM SHEET 1

RESULT

PRODUCT
CODE MRPQTY
AA3001202
CC3001224
DD2001235
II50012810

<colgroup><col width="64" span="4" style="width:48pt"> </colgroup><tbody>
</tbody>
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Try this:-
Code:
[COLOR="Navy"]Sub[/COLOR] MG06Mar34
[COLOR="Navy"]Dim[/COLOR] Rng1 [COLOR="Navy"]As[/COLOR] Range, Rng2 [COLOR="Navy"]As[/COLOR] Range, ray [COLOR="Navy"]As[/COLOR] Variant, Dn [COLOR="Navy"]As[/COLOR] Range, Ac [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long[/COLOR]
[COLOR="Navy"]Dim[/COLOR] R1 [COLOR="Navy"]As[/COLOR] Range, R2 [COLOR="Navy"]As[/COLOR] Range, Q [COLOR="Navy"]As[/COLOR] Variant, Rng [COLOR="Navy"]As[/COLOR] Range
[COLOR="Navy"]With[/COLOR] Sheets("Sheet1")
    [COLOR="Navy"]Set[/COLOR] Rng1 = .Range("A2", .Range("A" & Rows.Count).End(xlUp))
[COLOR="Navy"]End[/COLOR] With
[COLOR="Navy"]With[/COLOR] Sheets("Sheet2")
    [COLOR="Navy"]Set[/COLOR] Rng2 = .Range("A2", .Range("A" & Rows.Count).End(xlUp))
[COLOR="Navy"]End[/COLOR] With
ray = Array(Rng1, Rng2)
[COLOR="Navy"]With[/COLOR] CreateObject("scripting.dictionary")
.CompareMode = vbTextCompare
[COLOR="Navy"]For[/COLOR] Ac = 0 To 1
    [COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] Dn [COLOR="Navy"]In[/COLOR] ray(Ac)
        [COLOR="Navy"]Set[/COLOR] R1 = Nothing
        [COLOR="Navy"]Set[/COLOR] R2 = Nothing
        [COLOR="Navy"]If[/COLOR] Not .exists(Dn.Value) [COLOR="Navy"]Then[/COLOR]
            [COLOR="Navy"]If[/COLOR] Ac = 0 Then: [COLOR="Navy"]Set[/COLOR] R1 = Dn: Else: [COLOR="Navy"]Set[/COLOR] R2 = Dn
           .Add Dn.Value, Array(R1, R2)
        [COLOR="Navy"]Else[/COLOR]
            Q = .Item(Dn.Value)
              [COLOR="Navy"]If[/COLOR] Ac = 0 Then: [COLOR="Navy"]Set[/COLOR] Q(0) = Dn: Else: [COLOR="Navy"]Set[/COLOR] Q(1) = Dn
            .Item(Dn.Value) = Q
       [COLOR="Navy"]End[/COLOR] If
[COLOR="Navy"]Next[/COLOR]
[COLOR="Navy"]Next[/COLOR] Ac
[COLOR="Navy"]With[/COLOR] Sheets("Sheet3")
[COLOR="Navy"]Set[/COLOR] Rng = .Range("A2", .Range("A" & Rows.Count).End(xlUp))
[COLOR="Navy"]End[/COLOR] With
[COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] Dn [COLOR="Navy"]In[/COLOR] Rng
    [COLOR="Navy"]If[/COLOR] .exists(Dn.Value) [COLOR="Navy"]Then[/COLOR]
        Dn.Offset(, 1) = .Item(Dn.Value)(1).Offset(, 1)
        Dn.Offset(, 2) = .Item(Dn.Value)(0).Offset(, 1)
        Dn.Offset(, 3) = .Item(Dn.Value)(0).Offset(, 2)
    [COLOR="Navy"]End[/COLOR] If
[COLOR="Navy"]Next[/COLOR] Dn
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]With[/COLOR]
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Regards Mick
 
Upvote 0
lathish,

Please test the following macro on a copy or your workbook/worksheets.

Code:
Sub lathish()
' hiker95, 03/06/2018, ME1046267
Application.ScreenUpdating = False
Dim w1 As Worksheet, w2 As Worksheet, w3 As Worksheet
Dim r As Range, w2a As Range, w1a As Range
Set w1 = Sheets("SHEET 1")
Set w2 = Sheets("SHEET 2")
Set w3 = Sheets("SHEET 3")
With w3
  For Each r In .Range("A2", .Range("A" & Rows.Count).End(xlUp))
    Set w2a = w2.Columns(1).Find(r.Value, LookAt:=xlWhole)
    If Not w2a Is Nothing Then
      r.Offset(, 1).Value = w2.Range("B" & w2a.Row).Value
    End If
    Set w1a = w1.Columns(1).Find(r.Value, LookAt:=xlWhole)
    If Not w1a Is Nothing Then
      r.Offset(, 2).Value = w1.Range("B" & w1a.Row).Value
      r.Offset(, 3).Value = w1.Range("C" & w1a.Row).Value
    End If
  Next r
  .UsedRange.Columns.AutoFit
  .Activate
End With
Application.ScreenUpdating = True
End Sub
 
Upvote 0
how to link that code with excel or please tell me formulas

lathish,

Please TEST this FIRST in a COPY of your workbook (always make a backup copy before trying new code, you never know what you might lose).

1. Copy the macro code
2. Open your NEW workbook
3. Press the keys ALT + F11 to open the Visual Basic Editor
4. Press the keys ALT + I to activate the Insert menu
5. Press M to insert a Standard Module
6. Where the cursor is flashing, paste the code
7. Press the keys ALT + Q to exit the Editor, and return to Excel
8. To run the macro from Excel press ALT + F8 to display the Run Macro Dialog. Double Click the macro's name to Run it.

Before you use the macro with Excel 2007 or newer, save your workbook, Save As, a macro enabled workbook with the file extension .xlsm, and, answer the "do you want to enable macros" question as "yes" or "OK" (depending on the button label for your version of Excel) the next time you open your workbook.
 
Upvote 0

Forum statistics

Threads
1,215,494
Messages
6,125,139
Members
449,207
Latest member
VictorSiwiide

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top