Home |
Search |
Today's Posts |
#6
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
If you're using xl2k or higher, VBA has Replace. If you're using xl97 or below,
you can use application.substitute. Option Explicit Sub testme() Dim SpaceCtr As Long Dim myStr As String myStr = "asdf qwer qwer" 'myStr = Worksheets("sheet1").Range("a1").Value SpaceCtr = Len(myStr) - Len(Replace(myStr, " ", "")) MsgBox SpaceCtr 'or SpaceCtr = Len(myStr) - Len(Application.Substitute(myStr, " ", "")) MsgBox SpaceCtr End Sub wrote: I forgot to say that I'm in VBA and not in Excel. Is the Substitute function working in VBA too cause I got an error Thanks -- Dave Peterson |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
macro | Excel Discussion (Misc queries) | |||
Displays the number in text. (One thousand two hundred thirty four | Excel Worksheet Functions | |||
help with excel number string | Excel Discussion (Misc queries) | |||
Return SEARCHED Column Number of Numeric Label and Value | Excel Worksheet Functions | |||
last number array from string | Excel Worksheet Functions |