Trouble Extracting A String

Brad24

Board Regular
Joined
May 4, 2015
Messages
81
Hi, is there an easy way to extract a name from the following string?

The string has the following format. I just want James Bond out of this string.

James Bond J. Bond
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
I am getting an error trying to transfer it over to my code. It doesn't seem to like the "." so I changed it to this and it still says the code is wrong. My code is setting a formula

Workbooks(MyWorkbook).Sheets(MyWorksheet).Range("O1").Formula="=LEFT(A457, SEARCH(" & Chr(46) & ", A457) -2)"
 
Upvote 0
I got it! Thanks for the help.
Solution was to put this:
=LEFT(A457,SEARCH(" & Chr(34) & Chr(46) & Chr(34) & ", A457)-2)"
 
Upvote 0
aaarrrrrggggghhhhhh.
One of the names has three periods in it. Is it possible to deal with that with this code?

Example
D.J. Kennington D. Kennington
 
Upvote 0
aaarrrrrggggghhhhhh.
One of the names has three periods in it. Is it possible to deal with that with this code?

Example
D.J. Kennington D. Kennington
See if this code line works...
Code:
[table="width: 500"]
[tr]
	[td]Workbooks(MyWorkbook).Sheets(MyWorksheet).Range("O1").FormulaArray = "=LEFT(R[456]C[-14],MAX(IF(MID(R[456]C[-14],ROW(INDEX(C[-14],1):INDEX(C[-14],LEN(R[456]C[-14]))),1)=""."",ROW(INDEX(C[-14],1):INDEX(C[-14],LEN(R[456]C[-14])))))-3)"[/td]
[/tr]
[/table]
I am just wondering though... since you are using VB code, do you really need this code line to put a "live" formula in the cell... are you really expecting the value in cell A457 to be changed manually sometime after the formula has been placed such that you need a "live" formula in cell O1? If just placing the answer in the cell directly is acceptable, then you could use this code line to put the name in cell O1 directly...
Code:
[table="width: 500"]
[tr]
	[td]Workbooks(MyWorkbook).Sheets(MyWorksheet).Range("O1").Value = Left(Range("A457").Value, InStrRev(Range("A457").Value, ".") - 3)[/td]
[/tr]
[/table]
 
Last edited:
Upvote 0
Thanks Rick, that works but I have another issue that killed it. I was using some other code I have here that had the .Formula in it, but you are correct, I didn't need that in this case, so I will change it.

How do I get my Code into that format that you have?
IE Code:
and then it goes into that little box.

I have another name that this fails on: Ricky Stenhouse Jr. R. Stenhouse

I'm playing around with the SPLIT function. I "think" I can read the string into an array and then grab the first two in the array. I don't need the Jr. and that would get me by the names that have D.J. in them
 
Last edited:
Upvote 0
How do I get my Code into that format that you have?
IE Code:
and then it goes into that little box.
Either put select the text an click the button with the # sign or do what the # sign button does and place [/CODE] as the end of the text you want enclosed in the code box and put
Code:
 in front of it. If you wonder why I showed you those in reverse order is because if I put them in correct order, you would not see the codes as this forum's comment processor would have converted them into a code box.



[QUOTE="Brad24, post: 5016661, member: 325210"]I'm playing around with the SPLIT function. I "think" I can read the string into an array and then grab the first two in the array. I don't need the Jr. and that would get me by the names that have D.J.  in them
[/QUOTE]
Not necessarily... what if there was (what would be normally) an space between the two initials? Any chance you can post a list of one each of the variances you have in the names text (along with what you want from them) so that we can see all of the varieties you have to work around instead of getting them one at a time like you have been doing?
 
Last edited:
Upvote 0
Here is the list. I wasn't thinking ahead and didn't realize I needed to take into account the different variances. That got me there. I don't believe there will be any other variances. They are all in column A. The 3 rows for each guy are just 1 -40(40 drivers), than their name which I am trying to pull out, and then their car number, which I am also trying to pull out.

So from this, I need name and car number. Thought it was going to be easier than I have found as I had some similar help last weekend on something similar but just different enough that I can't figure it out.
1
Ryan Blaney R. Blaney
#12
2
Joey Logano J. Logano
#22
3
Austin Dillon A. Dillon
#3
4
Darrell Wallace Jr. D. Wallace Jr.
#43
5
Paul Menard P. Menard
#21
6
Michael McDowell M. McDowell
#34
7
Denny Hamlin D. Hamlin
#11
8
Ryan Newman R. Newman
#31
9
Chris Buescher C. Buescher
#37
10
Aric Almirola A. Almirola
#10
11
Trevor Bayne T. Bayne
#6
12
Martin Truex Jr. M. Truex Jr.
#78
13
Clint Bowyer C. Bowyer
#14
14
Alex Bowman A. Bowman
#88
15
AJ Allmendinger A. Allmendinger
#47
16
Kurt Busch K. Busch
#41
17
Jamie McMurray J. McMurray
#1
18
Ricky Stenhouse Jr. R. Stenhouse Jr.
#17
19
Kevin Harvick K. Harvick
#4
20
Kyle Larson K. Larson
#42
21
Kyle Busch K. Busch
#18
22
Gray Gaulding G. Gaulding
#23
23
Chase Elliott C. Elliott
#9
24
Jeffrey Earnhardt J. Earnhardt
#0
25
Mark Thompson M. Thompson
#166
26
William Byron W. Byron
#24
27
D.J. Kennington D. Kennington
#96
28
David Ragan D. Ragan
#38
29
Matt DiBenedetto M. DiBenedetto
#32
30
Brendan Gaughan B. Gaughan
#162
31
Erik Jones E. Jones
#20
32
Brad Keselowski B. Keselowski
#2
33
Daniel Suarez D. Suarez
#19
34
Kasey Kahne K. Kahne
#95
35
Danica Patrick D. Patrick
#7
36
Jimmie Johnson J. Johnson
#48
37
Ty Dillon T. Dillon
#13
38
Corey LaJoie C. LaJoie
#72
39
Justin Marks J. Marks
#51
40
David Gilliland D. Gilliland
#92

<tbody>
</tbody>
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,991
Messages
6,122,628
Members
449,095
Latest member
bsb1122

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top