Remove spaces from column headers

bfuchs
bfuchs used Ask the Experts™
on
Hi Experts,
I'm looking for either a VB function, script or DOS command that should do the following
remove all spaces from the all column names of a given excel sheet (or CSV file).
this should combine two words into one like "visit date" column should become VisitDate.
Thanks
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Bill PrewTest your restores, not your backups...
Top Expert 2016

Commented:
Please provide a sample input file.


»bp
Director of Technology Development, IPM
Commented:
For an Excel sheet - removes spaces from headers until it hits a blank header (assumes headers begin in Column A):
Sub RemoveSpaces()
rowNum = 1
colNum = 0
Range("A" & rowNum).Select
Do While (Selection.Offset(0, colNum) <> "")
   Selection.Offset(0, colNum) = Replace(Selection.Offset(0, colNum), " ", "")
   colNum = colNum + 1
Loop
End Sub

Open in new window

Thank you!
Sam JacobsDirector of Technology Development, IPM

Commented:
You are most welcome ...

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial