Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default Using the Find function to get Left or Right data

Can anyone help me figure out what I have wrong here. I think the code
shows what I am trying to do. The problem with simply using a Left()
or Right() function is the data size changes, of course and I am
splitting the data. I know this will work, but I can't get it to. I
keep getting the error: Sub or function not defined for Find.

strDWG = Range("J" & i & "").Value
'dwgNSN = Left(strDWG, 18)
dwgNSN = Left(strDWG, Find("/", strDWG) - 1)
'dwgMFR = Right(strDWG, 18)
dwgMFR = Right(strDWG, Find("/", strDWG) + 1)

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 486
Default Using the Find function to get Left or Right data

You did not mention exactly what you were trying to do but if you are trying
to split a string based on a delimeter (bacslash in this case) then you could
just use the split function which returns an array of the component peices of
the string...
--
HTH...

Jim Thomlinson


"Glen" wrote:

Can anyone help me figure out what I have wrong here. I think the code
shows what I am trying to do. The problem with simply using a Left()
or Right() function is the data size changes, of course and I am
splitting the data. I know this will work, but I can't get it to. I
keep getting the error: Sub or function not defined for Find.

strDWG = Range("J" & i & "").Value
'dwgNSN = Left(strDWG, 18)
dwgNSN = Left(strDWG, Find("/", strDWG) - 1)
'dwgMFR = Right(strDWG, 18)
dwgMFR = Right(strDWG, Find("/", strDWG) + 1)


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default Using the Find function to get Left or Right data

Thanks Jim and I saw the Split Function but I was not sure how I would
get the values split into dwgNSN and dwgMFR. I have data that looks
like 9I1234-01-234-5678 / 8H1234-02-345-6789. I need to get the data
on either side of the slash because sometimes my data looks like :
9I1234- / 8H1234-02-345-6789 or even - / -. I need to evaluate these
strings later for validity. Thanks.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 486
Default Using the Find function to get Left or Right data

This should be close to what you want...

Sub SplitString()
Dim aryStuff() As String
Dim strThis As String
Dim strThat As String

aryStuff = Split("9I1234-01-234-5678 / 8H1234-02-345-6789", "/")
strThis = Trim(aryStuff(0))
strThat = Trim(aryStuff(1))

MsgBox strThis
MsgBox strThat
End Sub
--
HTH...

Jim Thomlinson


"Glen" wrote:

Thanks Jim and I saw the Split Function but I was not sure how I would
get the values split into dwgNSN and dwgMFR. I have data that looks
like 9I1234-01-234-5678 / 8H1234-02-345-6789. I need to get the data
on either side of the slash because sometimes my data looks like :
9I1234- / 8H1234-02-345-6789 or even - / -. I need to evaluate these
strings later for validity. Thanks.


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Using the Find function to get Left or Right data


Hello Glen,

Have you tried using the InStr function? Here is your code with it
inserted...

strDWG = Range("J" & i & "").Value
'dwgNSN = Left(strDWG, 18)
dwgNSN = Left(strDWG, InStr(1, "/", strDWG) - 1)
'dwgMFR = Right(strDWG, 18)
dwgMFR = Right(strDWG, Len(strDWG) - InStr(1, "/", strDWG) )

Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=505850



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default Using the Find function to get Left or Right data

Thank you both. I was just using the InStr function while you two were
replying to see if it would work for me and it seems to do the job. I
am going to try the split just to see how it goes and keep it for
future reference. Thanks again to both of you.

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 486
Default Using the Find function to get Left or Right data

Looking at your origingal question I was initailly unsure just how many items
you needed to get from your string. For 2 the Instr function is great. For
more I use the split function, but both work just fine...
--
HTH...

Jim Thomlinson


"Glen" wrote:

Thank you both. I was just using the InStr function while you two were
replying to see if it would work for me and it seems to do the job. I
am going to try the split just to see how it goes and keep it for
future reference. Thanks again to both of you.


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
FIND from right to left instead of left to right David Excel Worksheet Functions 8 November 23rd 09 07:23 PM
LEFT function-all to left of a comma? Jennifer F Excel Worksheet Functions 1 January 21st 09 11:19 PM
Help putting left, right, find and len together Glenda Excel Discussion (Misc queries) 5 October 11th 08 11:25 AM
Left vs Left$ function Andy Excel Discussion (Misc queries) 5 May 6th 07 04:06 AM
DATA VALIDATION with LEFT function Gabe Excel Discussion (Misc queries) 2 May 6th 05 06:37 PM


All times are GMT +1. The time now is 06:17 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"