Macro to move one cell in column A to a cell in Column B

mmlehmann

New Member
Joined
Dec 30, 2014
Messages
16
I am attempting to create a Macro that allows me to cut a cell from column A and place in column B. For example I need a item cut from Cell A162 and pasted in Cell B161. I need the same Macro to cut cell A165 and pasted in Cell B164 ect... This will need to continue until cell A1374 is cut and pasted in cell B1373.
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Hey, welcome to the board!

Something similar to this should work:

Code:
[COLOR=#0000ff]Sub[/COLOR] Test()

    i = 161
   [COLOR=#0000ff] For[/COLOR] X = 162 [COLOR=#0000ff]To[/COLOR] 1374 [COLOR=#0000ff]Step[/COLOR] 3
        Range("A" & X).Cut
        Range("B" & i).Select
        ActiveSheet.Paste
        i = i + 3
 [COLOR=#0000ff]   Next[/COLOR] X

[COLOR=#0000ff]End Sub[/COLOR]

Copy A162 ---> Pastes to B161
Copy A165 ---> Pastes to B164
Copy A168 ---> Pastes to B167 ....etc
 
Upvote 0
Thanks for responding. When I ran that Macro it cut the cell from column A162 and pasted it into B162. I needed it to be moved from A162 to B161.

I appreciate your help!
 
Upvote 0
It seems to work fine for me. What code are you using?:

Before:

Excel 2012
AB
161
162A162 TEXT
163
164
165A165 TEXT
166
Sheet1




After:

Excel 2012
AB
160
161A162 TEXT
162
163
164A165 TEXT
165
Sheet1
 
Upvote 0
Sure no problem:

Look at this link for instructions: CLICK HERE

Use the code on a copy of your data. The changes macros make to your workbook are not reversible.
 
Upvote 0
Hey, welcome to the board!

Something similar to this should work:

Code:
[COLOR=#0000ff]Sub[/COLOR] Test()

   i = 161
   [COLOR=#0000ff] For[/COLOR] X = 162 [COLOR=#0000ff]To[/COLOR] 1374 [COLOR=#0000ff]Step[/COLOR] 3
        Range("A" & X).Cut
        Range("B" & i).Select
        ActiveSheet.Paste
        i = i + 3
 [COLOR=#0000ff]   Next[/COLOR] X

[COLOR=#0000ff]End Sub[/COLOR]

Copy A162 ---> Pastes to B161
Copy A165 ---> Pastes to B164
Copy A168 ---> Pastes to B167 ....etc

Just so you know, you can specify what to cut and where to cut it to in the same statement...

Code:
[COLOR=#0000ff]Sub[/COLOR] Test()

    i = 161
   [COLOR=#0000ff] For[/COLOR] X = 162 [COLOR=#0000ff]To[/COLOR] 1374 [COLOR=#0000ff]Step[/COLOR] 3
        Range("A" & X).Cut Range("B" & I)
        i = i + 3
   [COLOR=#0000ff] Next[/COLOR] X

[COLOR=#0000ff]End Sub[/COLOR]

And if you observe that the "copy to" row is always one less then the "copy from" row, you can simplify your code down to this...

Code:
[COLOR=#0000ff]Sub[/COLOR] Test()

    [COLOR=#0000ff]For[/COLOR] X = 162 [COLOR=#0000ff]To[/COLOR] 1374 [COLOR=#0000ff]Step[/COLOR] 3
        Range("A" & X).Cut Range("B" & X - 1)
    [COLOR=#0000ff]Next[/COLOR] X

[COLOR=#0000ff]End Sub[/COLOR]
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,324
Members
452,635
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top