Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 04-23-2018, 04:22 PM
NoSparks NoSparks is offline Extract States from a String Windows 7 64bit Extract States from a String Office 2010 64bit
Excel Hobbyist
 
Join Date: Nov 2013
Location: British Columbia, Canada
Posts: 842
NoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of light
Default

Assuming the sample string is in A1
Code:
Sub GetStates()
    Dim str As String, i As Integer
    Dim ar As Variant, arr As Variant
    
    str = Range("A1").Text
    str = Replace(Replace(Replace(Replace(Replace(str, "}", ""), "[", ""), "]", ""), """", ""), ",", "")
    ar = Split(str, "{")
    For i = LBound(ar) To UBound(ar)
        If InStr(ar(i), "state") > 0 Then
            arr = Split(ar(i), ":")
            MsgBox arr(UBound(arr))
        End If
    Next i
End Sub
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Extract States from a String Extract a string from a paragraph kirkm Word VBA 7 09-11-2016 06:13 PM
How to extract only numbers from a STRING? Learner7 Excel 3 07-02-2013 06:25 AM
Extract States from a String Extract Numbers from Alphanumeric String OTPM Excel 6 05-13-2011 12:52 AM
Extract numbers from a text string aleale97 Excel 4 02-10-2011 10:33 AM
Extract from String using Wildcard whousedmy Word 0 05-21-2009 01:35 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:12 PM.


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