Hello,
I am trying to figure out whether or not a string has a space in
its contents. I am using the following code.
(AppWSF is set equal to Application.WorksheetFunction)
If IsError(AppWSF.Find(" ", Given_Data.Value, 1)) = False Then
HasSpace = True
SpaceLoc = AppWSF.Find(" ", Given_Data.Value, 1)
End If
It works fine if there is a space in the string; however, it has an
error and quits running if there is no space in the string. Any help
would be appreciated!
Thanks,
bart.strubbe@scarlet.be - 20 Mar 2008 08:59 GMT
> Hello,
>
[quoted text clipped - 12 lines]
>
> Thanks,
without trying it myself
Replaced=replace(Given_data.value," ","")
if Replaced=Given_data.value then
HasSpace=true
else
HasSpace=false
endif
greetings
bart
bart.strubbe@scarlet.be - 20 Mar 2008 09:02 GMT
> > Hello,
>
[quoted text clipped - 24 lines]
>
> - Show quoted text -
sorry something wrong
if Replaced=Given_data.value then
must be
if Replaced<>Given_data.value then
bart
Dana DeLouis - 20 Mar 2008 12:08 GMT
> I am trying to figure out whether or not
> a string has a space in its contents.
Would this work?
Function HasSpaceQ(S As String) As Boolean
HasSpaceQ = S Like "* *"
End Function

Signature
HTH :>)
Dana DeLouis
> Hello,
>
[quoted text clipped - 12 lines]
>
> Thanks,
Dave Peterson - 20 Mar 2008 12:25 GMT
You could use VBA's equivalent of =find().
if instr(1, given_data.value, " ", vbtextcompare) > 0 then
'has a space
else
'doesn't have a space
end if
> Hello,
>
[quoted text clipped - 12 lines]
>
> Thanks,

Signature
Dave Peterson