Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-29-2020, 01:45 PM
Benali Benali is offline Want Macro to join lines and delete numbers Windows 10 Want Macro to join lines and delete numbers Office 2013
Novice
Want Macro to join lines and delete numbers
 
Join Date: Apr 2020
Posts: 10
Benali is on a distinguished road
Default Want Macro to join lines and delete numbers

Greetings,

I am not certain what to ask as my knowledge of macros is limited to excel. What i am trying to do is take a transcription form youtube video. Copy and paste to a word document and push a button to have it move all the lines together. Below is how the transcript looks. I want to eliminate the numbers that go from 00:00 to 99:99 and join the sentences together if its even possible. It is time consuming to delete , enter, space ect… as you can imagine. We appreciate your help in advance as i am sure there are some gurus on here.


00:04
and then this you probably were it was
00:07
been so hard for us United States
00:09
I think we've solved we've tried to get
00:15
a private decree in the United States
00:16
and then if I told you that I felt
00:18
fifteen people I probably not funny
00:20
every time I you know I helped a guy in
00:26
Florida this foreclosure he was studying
00:34
kept mailing it into the clerk should
00:36
keep returning it no notes we put a
00:40


money order everything we could think of
00:42
she returned the whole thing I like I'm
00:46
sorry what your state is doing it's just
Reply With Quote
  #2  
Old 04-29-2020, 03:15 PM
macropod's Avatar
macropod macropod is offline Want Macro to join lines and delete numbers Windows 7 64bit Want Macro to join lines and delete numbers 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

You could do this with a wildcard Find/Replace, where:
Find = ([0-9])^13
Replace = \1^t

No code required.

Note: the above inserts a TAB after the time. If you'd prefer a space, replace the ^t with a space character.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 04-29-2020, 04:02 PM
Benali Benali is offline Want Macro to join lines and delete numbers Windows 10 Want Macro to join lines and delete numbers Office 2013
Novice
Want Macro to join lines and delete numbers
 
Join Date: Apr 2020
Posts: 10
Benali is on a distinguished road
Default

macropod,

I honestly have no clue what to do with this. Can you "please" give me some instructions how to make it work
Reply With Quote
  #4  
Old 04-29-2020, 04:07 PM
macropod's Avatar
macropod macropod is offline Want Macro to join lines and delete numbers Windows 7 64bit Want Macro to join lines and delete numbers 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

Are you saying you don't even know how to use Find/Replace???
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 04-29-2020, 05:00 PM
Benali Benali is offline Want Macro to join lines and delete numbers Windows 10 Want Macro to join lines and delete numbers Office 2013
Novice
Want Macro to join lines and delete numbers
 
Join Date: Apr 2020
Posts: 10
Benali is on a distinguished road
Default

that I do, I was hoping for a macro to do it automatically? I guess I do not understand how to apply the formula
Reply With Quote
  #6  
Old 04-29-2020, 05:07 PM
Guessed's Avatar
Guessed Guessed is offline Want Macro to join lines and delete numbers Windows 10 Want Macro to join lines and delete numbers Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,977
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

If using Wildcards are not your thing, you can also do most of this by selecting it all and converting to a 2 column table separated by paragraphs. This will give you a column containing the time stamps and a second column containing the text. Then select the text column, copy it and use Paste Special to paste as Text Only to get just that text in consecutive paragraphs.

The final step would be to use Find and Replace to replace a paragraph mark '^p' with a space.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #7  
Old 04-29-2020, 05:13 PM
macropod's Avatar
macropod macropod is offline Want Macro to join lines and delete numbers Windows 7 64bit Want Macro to join lines and delete numbers 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

Even the macro recorder would give you a useable macro if you plugged the Find/Replace into it. That said, try:
Code:
Sub Demo()
Application.ScreenUpdating = False
With ActiveDocument.Range
  With .Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = "([0-9])^13"
    .Replacement.Text = "\1^t"
    .Forward = True
    .Format = False
    .Wrap = wdFindContinue
    .MatchWildcards = True
    .Execute Replace:=wdReplaceAll
  End With
End With
Application.ScreenUpdating = True
End Sub
For PC macro installation & usage instructions, see: Installing Macros
For Mac macro installation & usage instructions, see: Word:mac - Install a Macro
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #8  
Old 04-29-2020, 07:00 PM
Guessed's Avatar
Guessed Guessed is offline Want Macro to join lines and delete numbers Windows 10 Want Macro to join lines and delete numbers Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,977
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

I got the impression that Benali wants to get rid of the time stamps completely and merge the content into a single paragraph. When I copy/pasted from the original post, the lines were separated by a soft return rather than a paragraph mark so I'm going to assume that is what the code needs to work with.

If the above assumptions are right, building on from Paul's code try...
Code:
Sub Demo()
  Application.ScreenUpdating = False
  With ActiveDocument.Range
    With .Find
      .ClearFormatting
      .Replacement.ClearFormatting
      .Text = "([0-9:]{5})"
      .Replacement.Text = " "
      .Forward = True
      .Format = False
      .Wrap = wdFindContinue
      .MatchWildcards = True
      .Execute Replace:=wdReplaceAll
      .Text = "^l"   'or ^13
      .Replacement.Text = ""
      .Execute Replace:=wdReplaceAll
    End With
  End With
  Application.ScreenUpdating = True
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #9  
Old 04-29-2020, 07:14 PM
macropod's Avatar
macropod macropod is offline Want Macro to join lines and delete numbers Windows 7 64bit Want Macro to join lines and delete numbers 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

Quote:
Originally Posted by Guessed View Post
I got the impression that Benali wants to get rid of the time stamps completely and merge the content into a single paragraph.
You may be right there.
Quote:
Originally Posted by Guessed View Post
When I copy/pasted from the original post, the lines were separated by a soft return rather than a paragraph mark
That's liable to be due to the forum software.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #10  
Old 04-29-2020, 08:49 PM
Benali Benali is offline Want Macro to join lines and delete numbers Windows 10 Want Macro to join lines and delete numbers Office 2013
Novice
Want Macro to join lines and delete numbers
 
Join Date: Apr 2020
Posts: 10
Benali is on a distinguished road
Default

Quote:
Originally Posted by Guessed View Post
I got the impression that Benali wants to get rid of the time stamps completely and merge the content into a single paragraph. When I copy/pasted from the original post, the lines were separated by a soft return rather than a paragraph mark so I'm going to assume that is what the code needs to work with.

If the above assumptions are right, building on from Paul's code try...
Code:
Sub Demo()
  Application.ScreenUpdating = False
  With ActiveDocument.Range
    With .Find
      .ClearFormatting
      .Replacement.ClearFormatting
      .Text = "([0-9:]{5})"
      .Replacement.Text = " "
      .Forward = True
      .Format = False
      .Wrap = wdFindContinue
      .MatchWildcards = True
      .Execute Replace:=wdReplaceAll
      .Text = "^l"   'or ^13
      .Replacement.Text = ""
      .Execute Replace:=wdReplaceAll
    End With
  End With
  Application.ScreenUpdating = True
End Sub
when i run this code it takes away the numbers but does not place the line to the one above and make a complete sentence

Its like this


I sing sit home all morning really but

then you stepped up I'm glad but there's

not enough room for both of us this

morning so I'm gonna pass um we got a


and wish to have this:

I sing sit home all morning really but then you stepped up I'm glad but there's not enough room for both of us this morning so I'm gonna pass um we got a
Reply With Quote
  #11  
Old 04-29-2020, 11:02 PM
macropod's Avatar
macropod macropod is offline Want Macro to join lines and delete numbers Windows 7 64bit Want Macro to join lines and delete numbers 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 Demo()
Application.ScreenUpdating = False
With ActiveDocument.Range
  With .Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = "[^13^l][0-9]{2}:[0-9]{2}[!A-Za-z]@([A-Za-z])"
    .Replacement.Text = " \1"
    .Forward = True
    .Format = False
    .Wrap = wdFindContinue
    .MatchWildcards = True
    .Execute Replace:=wdReplaceAll
  End With
End With
Application.ScreenUpdating = True
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #12  
Old 04-30-2020, 07:57 AM
Benali Benali is offline Want Macro to join lines and delete numbers Windows 10 Want Macro to join lines and delete numbers Office 2013
Novice
Want Macro to join lines and delete numbers
 
Join Date: Apr 2020
Posts: 10
Benali is on a distinguished road
Default

Thank you and much love heading your way!!!!!! PERFECT!!!
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Want Macro to join lines and delete numbers Delete lines with just a number on them - use macro or find & replace? enso Word 2 05-20-2019 02:58 AM
Want Macro to join lines and delete numbers Select and Delete 2 lines after each blank line Ziad El Hachem Word VBA 4 03-21-2017 06:55 PM
Want Macro to join lines and delete numbers delete axis lines jhatter PowerPoint 2 06-04-2015 07:14 AM
How can I delete spaces & lines in a table cell mrayncrental Word VBA 3 10-20-2014 07:09 PM
Want Macro to join lines and delete numbers cannot delete these lines! userman Word 4 05-02-2012 12:34 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:07 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