Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

EXCEL: How can I remove spaces?

Status
Not open for further replies.

mrfritz44

MIS
Nov 21, 2003
75
US
I would like to start with a blank spreadsheet that uses some technique (macro, function?) to automatically remove spaces from a cell when text is pasted into it. Better yet, I would want to remove instances of double-spaces with nothing. The goal is to automate the process of forming a straight block of text from text that contains a lot of extraneous spaces.

I have this function, but I don't know how to use it:

Public Function RemoveSpaces(strInput As String)
' Removes all spaces from a string of text
Test:
If InStr(strInput, " ") = 0 Then
RemoveSpaces = strInput
Else
strInput = Left(strInput, InStr(strInput, " ") - 1) _
& Right(strInput, Len(strInput) - InStr(strInput, " "))
GoTo Test
End If
End Function


Any ideas?

Thanks,

Fred
 
Thank you very much Gavin. That last function is the ticket and the one I'll be using.

Have a good one,

Fred
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top