![]() |
|
#2
|
||||
|
||||
|
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. */ |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Convert Formula Result to Static Text | MYGS | Excel | 16 | 01-21-2013 08:18 AM |
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 |