Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Count number of tab characters in a string
Whats a quick way to count the number of tab characters in a string variable?
-Robert |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Count number of tab characters in a string
Hi Robert,
Am Wed, 9 Oct 2019 03:49:14 -0700 (PDT) schrieb RG III: What?s a quick way to count the number of tab characters in a string variable? try: i = Len(myStr) - Len(Replace(myStr, vbTab, "")) where is is the number of tab characters Regards Claus B. -- Windows10 Office 2016 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
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? |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Count number of tab characters in a string
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
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) |