Howdy, tricky one this....

Audiojoe

Active Member
Joined
Feb 20, 2002
Messages
285
I have a column of names, but they are downloaded and each cell with a name in it has a large number of spaces before the name itself. So for example, the data in a cell would look like this:

" Jimmy"

Can anyone give me some code that will lok down this column (column G) and remove all the spaces before the names?

I'd be really grateful for this

Thanks
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Hi joe

Try this

Code:
Sub GoAwaySpaces()

Columns(7).EntireColumn.Insert
    With Range("H1", Range("H65536").End(xlUp))
        .Offset(0, -1).FormulaR1C1 = "=TRIM(RC[1])"
        .Offset(0, -1) = .Offset(0, -1).Value
    End With
Columns(8).EntireColumn.Delete
 
End Sub
 
Upvote 0
You can also try this if ALL names have spaces in front. Hilite the column,from the Data Menu, Text to Columns, select Delimited from the first window and Spaces from the second. Note the column immediately to the right must be vacant.
 
Upvote 0

Forum statistics

Threads
1,214,583
Messages
6,120,383
Members
448,956
Latest member
JPav

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