Parse Cell in VBA

Myriad_Rocker

Board Regular
Joined
Dec 1, 2004
Messages
67
I've searched for a scenario like my situation to no avail. I've done this before but I'm having a brain fart at the moment and cannot, for the life of me, get this nailed down. I've done it in a round about way but I KNOW there is a better (and more consistent) approach.

I need to parse some string information that is in a cell, we'll say cell A1.

blah blah blah blah name="Example 1 Test" blah blah blah <duh="blah"

What I need is the information after name= without the quotes. So, I need to return Example 1 Test.

I know there's a relatively simple way to do this, but again, it escapes me. This is in VBA.
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Why VBA when a function will do:

=MID(A1,7,LEN(A1)-7)

Although you can easily convert that to VBA.

HTH,
 
Upvote 0
For using VBA, research the string manipulation functions on Google: InStr(), Mid(), Right() and Len(). A combination of these is what you need to use.
 
Upvote 0
Or

Code:
MsgBox Split(Range("A1").Value, """")(1)
 
Upvote 0
You've said blah blah blah in your example, but does that text contain quotation marks or do quotation marks only appear after name=
???
 
Upvote 0
Why VBA when a function will do
Because it's just a small part of a larger VBA project that I have.

For using VBA, research the string manipulation functions on Google: InStr(), Mid(), Right() and Len(). A combination of these is what you need to use.
Yes, I'm quite acclimated to those particular functions. But there's a succession of those that must be used.

You've said blah blah blah in your example, but does that text contain quotation marks or do quotation marks only appear after name=
???
Yes, that other part could contain (and does contain) quotation marks. Sorry.
 
Upvote 0
I got a version figured out. I say version because I'm sure there's multiple ways of doing this. Thanks to shg for the split example.

Code:
ReportName = (Mid(Range("A" & x).Value, InStr(1, Range("A" & x).Value, & _
     "name="), Len(Range("A" & x).Value) - InStr(1, Range("A" & x).Value, & _
     "name=")))
MsgBox Split(ReportName, """")(1)

As a note, the reason for the x variable is because I'm looping through the rows to the max row that has data. Just FYI.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,607
Messages
6,179,871
Members
452,948
Latest member
UsmanAli786

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