View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
RG III RG III is offline
external usenet poster
 
Posts: 65
Default Count number of tab characters in a string

On Wednesday, October 9, 2019 at 4:22:33 AM UTC-7, Claus Busch wrote:

i = Len(myStr) - Len(Replace(myStr, vbTab, ""))


It does not work with the following code:

str1 = "Apples oranges cakes"
i = Len(str1) - Len(Replace(str1, vbTab, ""))
MsgBox "Number of tabs: " & i

There are 4 tabs in str1, but it returns 0. It appears that tab
characters are converted to space characters in the VBA editor.
Might that be the problem?