Simple macro help

bbbuffalo

Board Regular
Joined
Apr 14, 2006
Messages
53
Well I think it should be simple.

I want to record a macro that starts from whatever cell I am currently in, then goes down one cell, to the left one cell, cuts that data, goes back to the right one cell, up one cell and pastes the data.

Then move down 2 cells.

A1 = Name
A2 = Phone
A3 = Name
A4 = Phone

I want to move the phone numbers to the B1, B3 position.
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
try to record macro with Relative References
Steps :
1. make Cell A1 Active cell
2. record macro --> Relative References
3. go down one step copy the cell then come back to B1
4. go to A3
5. Stop record macro

you get this macro
Code:
Sub Macro1()
'
' Macro1 Macro
'

'
    ActiveCell.Offset(1, 0).Range("A1").Select
    Selection.Copy
    ActiveCell.Offset(-1, 1).Range("A1").Select
    ActiveSheet.Paste
    Application.CutCopyMode = False
    ActiveCell.Offset(2, -1).Range("A1").Select
End Sub


then every time you run the code it will do one Move
if you want to move all cells
just add two lines

Do Until IsEmpty(ActiveCell)
and at end
Loop

your code will be like this
Code:
Sub Macro1()
'
' Macro1 Macro
'

Do Until IsEmpty(ActiveCell)
    ActiveCell.Offset(1, 0).Range("A1").Select
    Selection.Copy
    ActiveCell.Offset(-1, 1).Range("A1").Select
    ActiveSheet.Paste
    Application.CutCopyMode = False
    ActiveCell.Offset(2, -1).Range("A1").Select
Loop
End Sub


HTH
 
Upvote 0

Forum statistics

Threads
1,224,574
Messages
6,179,632
Members
452,933
Latest member
patv

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