Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 09-11-2016, 06:13 PM
Guessed's Avatar
Guessed Guessed is offline Extract a string from a paragraph Windows 10 Extract a string from a paragraph Office 2013
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,185
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

Graham's Macro3 code would be faster than the earlier alternatives of stepping through every paragraph.

I would suggest using InStr instead of .Start to get a bit more flexibility in where the found string might appear.
Code:
Sub Macro4()
  Dim oRng As Range
  Dim sText As String, sFind As String
  
  sFind = "010" & Chr$(9)
  Set oRng = ActiveDocument.Range
  With oRng.Find
    Do While .Execute(FindText:=sFind)
      sText = oRng.Paragraphs(1).Range.Text
      If InStr(sText, sFind) = 1 Then
        MsgBox sText
      End If
      oRng.Collapse 0
    Loop
  End With
lbl_Exit:
  Set oRng = Nothing
  Exit Sub
End Sub

__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Extract a string from a paragraph How to extract a word from an excel string with various lengths keywestsue Excel 3 09-18-2015 07:32 AM
How to extract only numbers from a STRING? Learner7 Excel 3 07-02-2013 06:25 AM
Extract a string from a paragraph 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 10:56 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