remove middle initial from name

dshafique

Board Regular
Joined
Jun 19, 2017
Messages
171
Hey guys, I have a worksheet with a lot of unstructured data and the middle initial after the first name screws with the alignment when I do text to columns for the data. the data comes from a txt file, and i have my delimiters as tab and space. its really annoying because some data I have

[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]brooke[/TD]
[TD]connected[/TD]
[TD]Feb[/TD]
[/TR]
[TR]
[TD]Angela[/TD]
[TD]Connected[/TD]
[TD]Mar
[/TD]
[/TR]
[TR]
[TD]Sharon[/TD]
[TD]L.[/TD]
[TD]Connected[/TD]
[/TR]
</tbody>[/TABLE]

is there a way for me to bring the middle initial in the same cell as the first name or remove it if i have to?
 
The code should look like this:
Code:
Sub MyDeleteMI()

    Dim lastRow As Long
    Dim myRow As Long
    
    Application.ScreenUpdating = False
    
    '   Find last entry in column G
    lastRow = Cells(Rows.Count, "G").End(xlUp).Row
    
    '   Loop through all entries in column G
    For myRow = 2 To lastRow
    '       If entry is two characters and ends in a period, delete it
        If Len(Cells(myRow, "G")) = 2 And Right(Cells(myRow, "G"), 1) = "." Then
            Cells(myRow, "F") = Cells(myRow, "F") & " " & Cells(myRow, "G")
            Cells(myRow, "G").Delete Shift:=xlToLeft
        End If
    Next myRow
            
    Application.ScreenUpdating = True
    
End Sub
 
Upvote 0

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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