Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 09-04-2015, 09:17 AM
rsrasc rsrasc is offline Need Help With Find and Replace Wildcard Windows 7 64bit Need Help With Find and Replace Wildcard Office 2010 64bit
Competent Performer
Need Help With Find and Replace Wildcard
 
Join Date: Mar 2014
Location: Germany
Posts: 148
rsrasc is on a distinguished road
Default Need Help With Find and Replace Wildcard

I have the below information in a document.

ACA-03380
ACA-03381
ACA-03382
ACA-03383
ACA-03384

I'm looking for a wildcard that will help me insert a list of sequential numbers starting with 1 using a input box. The desired output is shown below.

1. ACA-03380
2. ACA-03381
3. ACA-03382
4. ACA-03383
5. ACA-03384



As always thank you in advance for your support.
Reply With Quote
  #2  
Old 09-04-2015, 03:23 PM
gmaxey gmaxey is offline Need Help With Find and Replace Wildcard Windows 7 32bit Need Help With Find and Replace Wildcard Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,429
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey
Dim oRng As Word.Range
Dim lngIndex As Long
lngIndex = 1
Set oRng = ActiveDocument.Range
With oRng.Find
.Text = "ACA-^#^#^#^#^#"
While .Execute
oRng.InsertBefore lngIndex & ". "
lngIndex = lngIndex + 1
oRng.Collapse wdCollapseEnd
Wend
End With
lbl_Exit:
Exit Sub
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #3  
Old 09-04-2015, 04:02 PM
rsrasc rsrasc is offline Need Help With Find and Replace Wildcard Windows 7 64bit Need Help With Find and Replace Wildcard Office 2010 64bit
Competent Performer
Need Help With Find and Replace Wildcard
 
Join Date: Mar 2014
Location: Germany
Posts: 148
rsrasc is on a distinguished road
Default

Hi Greg,

Thank you for the code. It does the job. Great!!! I appreciate it.
Reply With Quote
  #4  
Old 10-13-2015, 08:39 AM
rsrasc rsrasc is offline Need Help With Find and Replace Wildcard Windows 7 64bit Need Help With Find and Replace Wildcard Office 2010 64bit
Competent Performer
Need Help With Find and Replace Wildcard
 
Join Date: Mar 2014
Location: Germany
Posts: 148
rsrasc is on a distinguished road
Default Extracting Data From A Document To Excel

A while back I was given a solution to my original request. Now, I'm trying to see if I can get help with my new request.

I have several files with a combination of letters and numbers.

They look like this:

1. ACA-03380
2. ACA-03390
3. ACA-03395
4. ACA-03450
5. ACA-03684
...
85. ACA-05784
...
92. ACA-08898

I would like to see if the above information could be extracted or copy to the bottom of the same document or if they can be exported to an excel file.

My preference will be to Excel.


Thanks in advanced.

Cheers!

Last edited by macropod; 10-13-2015 at 09:30 AM. Reason: Deleted unnecessary quote of entire previous posts in same thread...
Reply With Quote
  #5  
Old 10-13-2015, 09:33 AM
macropod's Avatar
macropod macropod is offline Need Help With Find and Replace Wildcard Windows 7 64bit Need Help With Find and Replace Wildcard Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Why do you need a macro? Can't you just copy the data and paste them into Excel? Aside from which, you haven't told us whether you want to use an existing workbook or a new one, etc.

PS: Unnecessarily quoting entire posts just adds clutter.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #6  
Old 10-13-2015, 11:16 AM
rsrasc rsrasc is offline Need Help With Find and Replace Wildcard Windows 7 64bit Need Help With Find and Replace Wildcard Office 2010 64bit
Competent Performer
Need Help With Find and Replace Wildcard
 
Join Date: Mar 2014
Location: Germany
Posts: 148
rsrasc is on a distinguished road
Default

Thank you Paul for your response. I will try not to clutter again.

So going back to your reply, I don't know if a macro if needed or not.


I can't copy and paste them into Excel because in between the numbers I have information.

My option (if available) is to have exported into a new Excel document.


Here is how the information looks like after the ACA-XXXXX numbers (listed from 1 to 3).

Thanks!





1d. ACA-03626 Which of the follsosdwing procedures XXXXwoSSSSuld an entity most lSSSSSikely incSSSSlude in its disaster recovery plan?
a. xxxCcocncvcecrctc a.
b. Maintssfadisns sas stsrojan horse program to prevent illicit activity.
c. Devselop an auxiliasfdsssbsrsy sspsty.
d. Stodrse dupsddslsiscsastfes ffdcfof.


Answer: D
Answer (A) xxxx.


Answer (B) xxxx.


Answer (C) xxxx.


Answer (D} xxxx.


2. ACA-03631 Which of the follsosdwing procedures XXXXwoSSSSuld an entity most lSSSSSikely incSSSSlude in its disaster recovery plan?
a. xxxCcocncvcecrctc a.
b. Maintssfadisns sas stsrojan horse program to prevent illicit activity.
c. Devselop an auxiliasfdsssbsrsy sspsty.
d. Stodrse dupsddslsiscsastfes ffdcfof.


Answer: D
Answer (A) xxxx.


Answer (B) xxxx.


Answer (C) xxxx.


Answer (D} xxxx.



3. ACA-Which of the follsosdwing procedures XXXXwoSSSSuld an entity most lSSSSSikely incSSSSlude in its disaster recovery plan?
a. xxxCcocncvcecrctc a.
b. Maintssfadisns sas stsrojan horse program to prevent illicit activity.
c. Devselop an auxiliasfdsssbsrsy sspsty.
d. Stodrse dupsddslsiscsastfes ffdcfof.


Answer: D
Answer (A) xxxx.


Answer (B) xxxx.


Answer (C) xxxx.


Answer (D} xxxx.
Reply With Quote
  #7  
Old 10-13-2015, 01:03 PM
macropod's Avatar
macropod macropod is offline Need Help With Find and Replace Wildcard Windows 7 64bit Need Help With Find and Replace Wildcard Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Your example is confusing. Do some of these numbered pargraphs have content between the number and ACA as your "1d. ACA-03626" shows?
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #8  
Old 10-13-2015, 01:26 PM
rsrasc rsrasc is offline Need Help With Find and Replace Wildcard Windows 7 64bit Need Help With Find and Replace Wildcard Office 2010 64bit
Competent Performer
Need Help With Find and Replace Wildcard
 
Join Date: Mar 2014
Location: Germany
Posts: 148
rsrasc is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
Your example is confusing. Do some of these numbered pargraphs have content between the number and ACA as your "1d. ACA-03626" shows?
I did not see that. The letter d after number 1 should not be there. Sorry for the confusion--so there is no content between the number and ACA.

But there is (are) content between the listed numbers with their associated ACA-XXXXX (number)

1. ACA-03626
2. ACA-03656
3. ACA-03697
..
95. ACA-08566
..
125. ACA-09633

Hope this help.

Thanks!
Reply With Quote
  #9  
Old 10-13-2015, 01:52 PM
macropod's Avatar
macropod macropod is offline Need Help With Find and Replace Wildcard Windows 7 64bit Need Help With Find and Replace Wildcard Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Try:
Code:
Sub ExportData()
Dim StrData As String, StrTmp As String, i As Long
Dim xlApp As Object, xlWkBk As Object
With ActiveDocument.Range
  .InsertBefore vbCr
  With .Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = "^13[0-9]{1,}. ACA-[0-9]{5}"
    .Replacement.Text = ""
    .Forward = True
    .Wrap = wdFindStop
    .Format = False
    .MatchWildcards = True
    .Execute
  End With
  Do While .Find.Found
    StrData = StrData & .Text
    .Collapse wdCollapseEnd
    .Find.Execute
  Loop
  Undo 1
End With
' Test whether Excel is already running.
On Error Resume Next
Set xlApp = GetObject(, "Excel.Application")
'Start Excel if it isn't running
If xlApp Is Nothing Then
  Set xlApp = CreateObject("Excel.Application")
  If xlApp Is Nothing Then
    MsgBox "Can't start Excel.", vbExclamation
    Exit Sub
  End If
End If
On Error GoTo 0
With xlApp
  Set xlWkBk = .Workbooks.Add
  ' Update the workbook.
  With xlWkBk.Worksheets(1)
    For i = 1 To UBound(Split(StrData, vbCr))
      .Cells(i, 1).Value = Split(StrData, vbCr)(i)
    Next
  End With
  ' Tell the user we're done.
  MsgBox "Data extraction finished.", vbOKOnly
  ' Switch to the Excel workbook
  .Visible = True
End With
' Release object memory
Set xlWkBk = Nothing: Set xlApp = Nothing
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #10  
Old 10-13-2015, 02:37 PM
rsrasc rsrasc is offline Need Help With Find and Replace Wildcard Windows 7 64bit Need Help With Find and Replace Wildcard Office 2010 64bit
Competent Performer
Need Help With Find and Replace Wildcard
 
Join Date: Mar 2014
Location: Germany
Posts: 148
rsrasc is on a distinguished road
Default

Thanks! The execution of the code is really fast.


Working great!


Thank you for your support.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Need Help With Find and Replace Wildcard Wildcard Find and Replace anomaly BruceM Word 3 07-10-2015 04:33 AM
Need Help With Find and Replace Wildcard New Find/Replace Wildcard Needed rsrasc Word VBA 2 11-11-2014 09:46 AM
Need Help With Find and Replace Wildcard Find/Replace Wildcard Needed rsrasc Word VBA 4 11-11-2014 08:28 AM
Need Help With Find and Replace Wildcard Wildcard Find and Replace Ulodesk Word 1 06-23-2014 10:26 AM
Need Help With Find and Replace Wildcard Need help using WildCard Find & Replace Cayce Word 1 06-09-2014 04:17 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:39 PM.


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