Forum Discussion
Append portion of even number rows to odd number rows
Sub principal()
Dim i, j, k, l As Long
Range("G:L").Clear
k = 1
l = 1
j = Range("A" & Rows.Count).End(xlUp).Row
For i = 2 To j Step 2
Cells(k, 7).Value = Cells(l, 1).Value
Cells(k, 8).Value = Cells(l, 3).Value
Cells(k, 9).Value = Cells(l, 5).Value
l = l + 2
Cells(k, 10).Value = Cells(i, 1).Value
Cells(k, 11).Value = Cells(i, 3).Value
Cells(k, 12).Value = Cells(i, 5).Value
k = k + 1
Next i
End Sub
You can try this code. In the attached file you can click the button in cell N2 to run the macro.
How do I get the contents of your cell N2 into a specific cell in my Excel file?
- OliverScheurichApr 09, 2023Gold Contributor
The easiest possibility would be if you copied your data and pasted it into the file that i sent you in an earlier reply.
If you want the code in your file you have to enter the code into a module. In your worksheet you can press alt+F11 in order to open the VBA editor. Then you can select insert (Einfügen in german Excel)-> module to add a module. Then copy the code into the module and close the editor.
Then you can add a button in your worksheet in any cell you want. Therefore under "insert" (Einfügen in german Excel) select "shapes" and square (or any shape you prefer). Then enter the shape in any cell you want. To do this press the left-click with the mouse and drag the square across a cell.
Then you can right-click in the shape and select "assign macro".
Then select the macro that you want to assign to the shape and click ok.
Then you can run the macro with a click on the shape.