Simple VBA to move down one cell, and insert

ExcelNoob2024

New Member
Joined
Sep 17, 2024
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Hi There

I am new here but have used the board for years to help with things I need to do on Excel. What I need to do is stumping me and I would like a little help please.

I have a sheet that has a Company Name in every Odd Cell Row (1, 3, 5 etc.) and the region they are based in, in every Even Cell Row (2, 4, 6 etc.)

I want to write a simple VBA that would move down to every even cell, shift that cell to the right and then move on until it runs out of cells.

Please can you assist me :)

Thanks
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Welcome to the Board!

Here is one way:
VBA Code:
Sub MyMoveCells()

    Dim lr As Long
    Dim r As Long
    
    Application.ScreenUpdating = False
    
'   Find last row in column A with data
    lr = Cells(Rows.Count, "A").End(xlUp).Row
    
'   Loop through every other row starting in row 2
    For r = 2 To lr Step 2
'       Move cell over to column B
        Cells(r, "B").Value = Cells(r, "A").Value
        Cells(r, "A").ClearContents
    Next r
    
    Application.ScreenUpdating = True
    
End Sub

Here is the before picture:
1726569431124.png


and here is the data after we run the code:
1726569466546.png
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,160
Members
453,021
Latest member
Justyna P

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