moving values between cells?

termeric

Active Member
Joined
Jun 21, 2005
Messages
280
hello,

i have a spread sheet that came to me filled with first and last names all in one column. i went ahead and spread the names over 3 columns using "text to columns".

what im left with now, is a coulmn for the first name(FN), middle initial(MI), and last name(LN). the only problem i encountered is that some people dont have middle initials, so their LN column is blank, and thier MI column has their last name.

can some one please help me with a script that will check the last name column, and if it is blank, take the value out of the middle initial column, and move it over, leaving a blank cell in the MI column?



thanks,

- christian
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
here's a vba solution to your problem, assuming the range is named "names" and it starts in column A (in a 3 column format).
Code:
Public Sub MoveLastnames()
Dim myRow As Integer

With Range("names")
    For myRow = 1 To .Rows.Count + 1
        If Cells(myRow, 3).Value = "" Then
            Cells(myRow, 3).Value = Cells(myRow, 2)
            Cells(myRow, 2).Clear
        End If
    Next myRow
End With

End Sub
 
Upvote 0

Forum statistics

Threads
1,221,639
Messages
6,160,998
Members
451,682
Latest member
ogoreo

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