Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
How would I catch the error if the string does not have a space in it and save the value as it is in that case? For iCtr = 2 To OldLusedrow OldString = ws.Range("B" & iCtr).Value ws.Range("A" & iCtr).Value = Left(OldString, InStr(OldString, " ") - 1) Next -- Thanks for your help. Karen53 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Dim SpacePos as long
For iCtr = 2 To OldLusedrow OldString = ws.Range("B" & iCtr).Value spacepos = instr(1, oldstring, " ", vbtextcompare) if spacepos = 0 then 'no spaces, so no changes else ws.range("a" & ictr).value = left(oldstring, spacepos-1) end if next ictr Maybe??????? Karen53 wrote: Hi, How would I catch the error if the string does not have a space in it and save the value as it is in that case? For iCtr = 2 To OldLusedrow OldString = ws.Range("B" & iCtr).Value ws.Range("A" & iCtr).Value = Left(OldString, InStr(OldString, " ") - 1) Next -- Thanks for your help. Karen53 -- Dave Peterson |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Never Mind. I got it.
Thanks -- Thanks for your help. Karen53 "Karen53" wrote: Hi, How would I catch the error if the string does not have a space in it and save the value as it is in that case? For iCtr = 2 To OldLusedrow OldString = ws.Range("B" & iCtr).Value ws.Range("A" & iCtr).Value = Left(OldString, InStr(OldString, " ") - 1) Next -- Thanks for your help. Karen53 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Karen
Dim test as Integer Dim Newstring as String For iCtr = 2 To OldLusedrow OldString = ws.Range("B" & iCtr).Value Test=Instr(OldString," ") If Test = 0 then Newstring = Oldstring Else Newstring = Left(Oldstring, test) End If ws.Range("A" & iCtr).Value = NewString Next -- Regards Roger Govier "Karen53" wrote in message ... Hi, How would I catch the error if the string does not have a space in it and save the value as it is in that case? For iCtr = 2 To OldLusedrow OldString = ws.Range("B" & iCtr).Value ws.Range("A" & iCtr).Value = Left(OldString, InStr(OldString, " ") - 1) Next -- Thanks for your help. Karen53 |