eliminate blank in string

User avatar
sal21
PlatinumLounger
Posts: 4355
Joined: 26 Apr 2010, 17:36

eliminate blank in string

Post by sal21 »

I have a var="sssssss yutyutyu b "

how to eliminate a blank space and reain only one?

I remember is possible with excel.application but not remember the rest of code :grin:

User avatar
HansV
Administrator
Posts: 78493
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: eliminate blank in string

Post by HansV »

Code: Select all

Dim varS As String
varS = "sssssss                  yutyutyu b               "
' Remove leading spaces, trailing spaces and replace multiple spaces with single ones
varS = Application.WorksheetFunction.Trim(varS)
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4355
Joined: 26 Apr 2010, 17:36

Re: eliminate blank in string

Post by sal21 »

HansV wrote:

Code: Select all

Dim varS As String
varS = "sssssss                  yutyutyu b               "
' Remove leading spaces, trailing spaces and replace multiple spaces with single ones
varS = Application.WorksheetFunction.Trim(varS)
yeah!!!!!!
Work fine. :thankyou: