Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 06-04-2013, 09:33 AM
BobBridges's Avatar
BobBridges BobBridges is offline extract text with formula Windows 7 64bit extract text with formula Office 2010 32bit
Expert
 
Join Date: May 2013
Location: USA
Posts: 700
BobBridges has a spectacular aura aboutBobBridges has a spectacular aura about
Default

Hi, Barry. As always in programming, there's more than one way to do this. You can do it manually with the InStr function. You can use the Split function (good more more than just space-delimited words). You can also use Regular Expressions, which is an advanced topic but can be very useful when your pattern-recognition needs are complex.

Let me ask about a couple of sample cases:

"123/456/789/abc/def": You want to extract "456".
"Now is the/time for all/good men...///": You want "time for all".
"$4,213.99/N": You want "".

But what about these:
"///": ""?
"tuhe/N/thueat": ""?
"$4,213.99/": ""? The same whether there's an 'N' or not, in other words?

If I'm guessing right in the above three cases, then it seems to me the simplest way to do this is to use the Split function, like this:

' As the code begins, StrVal = "something/something/something..."
arr = Split(StrVal, "/") 'creates an array starting with arr(0)
Value2 = arr(1) 'the second value
If Value2 = "N" then Value2 = ""

If you see a problem with any of my test questions, then maybe some other logic would have to be used.

/* Standard warning: I haven't tested this logic, I'm just spinning it up off the top of my head. Test before trusting. */
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert Formula Result to Static Text MYGS Excel 16 01-21-2013 08:18 AM
extract text with formula If formula result is negative then display text oxicottin Excel 3 12-03-2012 02:12 AM
Formula that references cell with text in different workbook no1texan Excel 3 07-17-2012 05:58 AM
Extract numbers from a text string aleale97 Excel 4 02-10-2011 10:33 AM
Extract Photographs The Gap PowerPoint 4 04-22-2010 07:00 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:13 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft