move cell macro

kendel

Board Regular
Joined
Mar 2, 2010
Messages
133
Hello,
Here's a task I want to automate. This is a macro I did with the macro recorder to move the contents of a cell to the cell next to it.

movemacro
Selection.Cut Destination:=ActiveCell.Offset(0,1).Range("A1")
ActiveCell.Offset(0,1).Range("A1").Select

Now, using Ctrl select to select random cells in column G, 30 cells or so, I would like to move all the selected cells one cell to the right, staying in the same row.
I'm using WinXP and Windows7 with Excel2007.

I posted this before but I didn't explain it well enough to get a workable solution.

Thanks for any help on this.
Kendel
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
A single line should do it:

Selection.Offset(0, 1) = Selection.Value

This macro doesn't work for formulas: It only writes the formula values.
 
Upvote 0
Thank you for your response, unfortunately that one line in a macro only copies the first cell into the column next to all the cells selected. Did I miss something? Remember the cells are selected with the Ctrl key, they have cells with data that I don't want to move between them, and I want to move/cut the data not copy it. An example would be to move the data in A1 to B1, A3 to B3, A5 to B5,...A19 to B19,... all at the same time. A loop of somekind seems to be whats needed but I don't know how to do it.
Any suggestions?

thanks agaiin for the response!
 
Upvote 0
nightcrawler23 thank you for the response, the macro cuts the selected cells, but inputs only the data of the first cell selected next to all the other selected cells. A1 to B1, A1 to B3,...A1 to B19. Did I leave something out of the macro?
thanks again!
 
Upvote 0
Code:
Sub temp()
Dim myRA As Range
Set myRA = Selection
 
For Each cl In myRA
   cl.Offset(0, 1) = cl.Value
   cl.Clear
Next cl
 
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,771
Members
452,353
Latest member
strainu

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