Macro to Remove Extra Spaces in a row

Michael151

Board Regular
Joined
Sep 20, 2010
Messages
247
Hello all,

I have an Excel sheet from an Access querie that has a header in row containing extra spaces in each cell.

What I'm trying to do is match headers with another sheet and unfortunately because of the spaces, the headers don't match (even though they appear to).

Would there be a way to write a macro that will remove any extra spaces in row 1?

Help is most appreciated!
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Do the headers change? If not, can you just put the headers in correctly one time and paste the data starting in row 2 and then delete row 2 which would be the bad set of headers?
 
Upvote 0
The headers don't change (I need them to match exactly), but I'm dealing with potentially over a hundred columns and a number of worksheets. manually cutting and pasting would take a very long time, which is why i'm trying to write a macro to do this.
 
Upvote 0

Forum statistics

Threads
1,224,502
Messages
6,179,126
Members
452,890
Latest member
Nikhil Ramesh

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