ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   macro beginner (https://www.excelbanter.com/excel-programming/335840-re-macro-beginner.html)

Rowan[_2_]

macro beginner
 
Hi Erica

You need to give us some more details. Which column is your data in? Does it
start in row 1 or do you have headings? Are you sure you want to move the 3rd
row up one or do you want to move it up 2 rows to be in the same row as the
other data?

Assuming your data is in column A starting in row 1 and you want your
results on one line then this should work.

Sub Move()

Dim lRow As Long
Dim myCol As Range
Dim Cell As Range

lRow = Cells(Rows.Count, 1).End(xlUp).Row
Set myCol = Range(Cells(1, 1), Cells(lRow, 1))
For Each Cell In myCol
Select Case Cell.Row Mod 3
Case 2
Cell.Offset(-1, 1).Value = Cell.Value
Cell.Value = ""
Case 0
Cell.Offset(-2, 2).Value = Cell.Value
Cell.Value = ""
End Select
Next Cell

End Sub

Regards
Rowan


"Erica" wrote:

Hi, I would like a macro that from one column cuts and pasts from every 2nd
row into the next (2nd) column (one row up) and that for every 3rd row cuts
and past that value into the 3rd column (also one row up). I have recorded
the macro but the cell values are fixed. Thanks!

Erica



All times are GMT +1. The time now is 06:50 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com