May 06 2022 02:24 AM
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.
May 06 2022 02:55 AM
SolutionHere 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
May 06 2022 03:00 AM
@SamSh84 Created a smaller version of your workbook. See attached. No VBA needed.
May 06 2022 02:55 AM
SolutionHere 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