SOLVED

Copy using cell name column

%3CLINGO-SUB%20id%3D%22lingo-sub-3331494%22%20slang%3D%22en-US%22%3ECopy%20using%20cell%20name%20column%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3331494%22%20slang%3D%22en-US%22%3E%3CP%3EHello%20%2C%3C%2FP%3E%3CP%3EHow%20can%20I%20check%20the%20number%20of%20the%20cell%20from%20right%20(B2%2CB3%2CB4......)%20and%20copy%20the%20content%20of%20cell%20(A2%2CA3%2CA4....)from%20right%20to%20the%20left%20side%20based%20on%20the%20cell%20number%20(B2%2CB3%2CB4%2C....)%20from%20right%26nbsp%3B%20%2C%20using%20a%20macro%20or%20VBA%20code%20.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Enote%20%3A%3C%2FP%3E%3CP%3Ewe%20can%20combine%202%20files%20together%20in%20same%20sheet.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ethanks.%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22copy%20excel.png%22%20style%3D%22width%3A%20649px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F369762i7825B20E914B1A1E%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22copy%20excel.png%22%20alt%3D%22copy%20excel.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-3331494%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3331743%22%20slang%3D%22en-US%22%3ERe%3A%20Copy%20using%20cell%20name%20column%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3331743%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1382668%22%20target%3D%22_blank%22%3E%40SamSh84%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EHere%20is%20such%20a%20macro%3A%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-visual-basic%22%3E%3CCODE%3ESub%20FillData()%0A%20%20%20%20Dim%20w1%20As%20Worksheet%0A%20%20%20%20Dim%20w2%20As%20Worksheet%0A%20%20%20%20Dim%20r%20As%20Long%0A%20%20%20%20Dim%20m%20As%20Long%0A%20%20%20%20Application.ScreenUpdating%20%3D%20False%0A%20%20%20%20'%20Change%20the%20names%20of%20the%20sheets%20as%20needed%0A%20%20%20%20Set%20w1%20%3D%20Worksheets(%22Sheet1%22)%0A%20%20%20%20Set%20w2%20%3D%20Worksheets(%22Sheet2%22)%0A%20%20%20%20m%20%3D%20w2.Range(%22B%22%20%26amp%3B%20w2.Rows.Count).End(xlUp).Row%0A%20%20%20%20For%20r%20%3D%202%20To%20m%0A%20%20%20%20%20%20%20%20w1.Range(w2.Range(%22B%22%20%26amp%3B%20r).Value).Value%20%3D%20w2.Range(%22A%22%20%26amp%3B%20r).Value%0A%20%20%20%20Next%20r%0A%20%20%20%20Application.ScreenUpdating%20%3D%20True%0AEnd%20Sub%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3331755%22%20slang%3D%22en-US%22%3ERe%3A%20Copy%20using%20cell%20name%20column%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3331755%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1382668%22%20target%3D%22_blank%22%3E%40SamSh84%3C%2FA%3E%26nbsp%3BCreated%20a%20smaller%20version%20of%20your%20workbook.%20See%20attached.%20No%20VBA%20needed.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3336633%22%20slang%3D%22en-US%22%3ERe%3A%20Copy%20using%20cell%20name%20column%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3336633%22%20slang%3D%22en-US%22%3EThank%20You%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3336634%22%20slang%3D%22en-US%22%3ERe%3A%20Copy%20using%20cell%20name%20column%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3336634%22%20slang%3D%22en-US%22%3EThank%20You%3C%2FLINGO-BODY%3E
New Contributor

Hello ,

How can I check the number of the cell from right (B2,B3,B4......) and copy the content of cell (A2,A3,A4....)from right to the left side based on the cell number (B2,B3,B4,....) from right  , using a macro or VBA code .

 

note :

we can combine 2 files together in same sheet.

 

thanks.

copy excel.png

 

 

4 Replies
best response confirmed by SamSh84 (New Contributor)
Solution

@SamSh84 

Here is such a macro:

Sub FillData()
    Dim w1 As Worksheet
    Dim w2 As Worksheet
    Dim r As Long
    Dim m As Long
    Application.ScreenUpdating = False
    ' Change the names of the sheets as needed
    Set w1 = Worksheets("Sheet1")
    Set w2 = Worksheets("Sheet2")
    m = w2.Range("B" & w2.Rows.Count).End(xlUp).Row
    For r = 2 To m
        w1.Range(w2.Range("B" & r).Value).Value = w2.Range("A" & r).Value
    Next r
    Application.ScreenUpdating = True
End Sub

@SamSh84 Created a smaller version of your workbook. See attached. No VBA needed.

 

Thank You
Thank You