VBA for moving data

imported_unknown

Active Member
Joined
Jan 13, 2002
Messages
424
I got a spdsht with imported names and addresses. The name appears in B1 and the corresponding address appears in B2. The same pattern continues for whatever number of names there are in the file. The address needs to be moved up to C1 for each record.I think I can probably write a 'Loop' that will move them all individually, but was wondering if there is a better way. (perhaps code that will get the program to take the data on every other row and move it)

Any help will be much appreciated. Thanks.
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Here is a VBA method, which has the advantage of deleting the address rows:

Code:
Sub Test()
    Dim Rng As Range
    Dim x As Long
    Set Rng = Range("B1:B" & Range("B65536").End(xlUp).Row)
    x = 1
    Do
        If IsEmpty(Rng.Cells(x, 1)) Then Exit Sub
        Rng.Cells(x, 2).Value = Rng.Cells(x, 1).Offset(1, 0).Value
        Rng.Cells(x, 1).Offset(1, 0).EntireRow.Delete
        x = x + 1
    Loop
End Sub
 
Upvote 0

Forum statistics

Threads
1,222,102
Messages
6,163,942
Members
451,866
Latest member
cradd64

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