View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Count spaces in front of text

And maybe a little more generic:

Option Explicit

Public Sub Tester()
Const sStr As String = " Jean"
Dim iSpaces As Long

iSpaces = InStr(1, sStr, Left(Trim(sStr), 1), vbTextCompare) - 1
MsgBox iSpaces
End Sub

Norman Jones wrote:

Hi Poppy,

Try:

'=============
Public Sub Tester()
Const sStr As String = " Jean"
Dim iSpaces As Long

iSpaces = InStr(1, sStr, "J") - 1
MsgBox iSpaces
End Sub
'<<=============

---
Regards,
Norman

"poppy" wrote in
message ...

Hi

Is it possible to count the number of spaces that appear before a text
in vba?

E.g. " Jean" = 3

I really would appreciate some help on this.

Thanks and Kind Regards


--
poppy
------------------------------------------------------------------------
poppy's Profile:
http://www.excelforum.com/member.php...o&userid=11453
View this thread: http://www.excelforum.com/showthread...hreadid=558439


--

Dave Peterson