SOLVED

Copy using cell name column

Copper 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 (Copper 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
1 best response

Accepted Solutions
best response confirmed by SamSh84 (Copper 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

View solution in original post