Home |
Search |
Today's Posts |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
RG III wrote:
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? Yes. Try this: str1 = "Apples" & vbTab & vbTab & "oranges" & vbTab & vbTab & "cakes" i = Len(str1) - Len(Replace(str1, vbTab, "")) MsgBox "Number of tabs: " & i -- If you have an apple and I have an apple and we exchange apples then you and I will still each have one apple. But if you have an idea and I have an idea and we exchange these ideas, then each of us will have two ideas. -- George Bernard Shaw |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How can I count the number of characters on a cell? | Excel Discussion (Misc queries) | |||
Count characters within a string | Excel Worksheet Functions | |||
Count the number of characters created by string text | Excel Programming | |||
trim a string by specific number of characters | Excel Discussion (Misc queries) | |||
Count Number of Characters in a cell? | Excel Discussion (Misc queries) |