Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 11-12-2023, 12:00 PM
vivka vivka is offline Can somebody help me with a macro to move a line two lines down? Windows 7 64bit Can somebody help me with a macro to move a line two lines down? Office 2016
Expert
 
Join Date: Jul 2023
Posts: 305
vivka is on a distinguished road
Default

Hi! It's quite simple:
Code:
Sub Move_Two_Lines_Down()

Dim Rng As range

Set Rng = selection.range

Application.ScreenUpdating = False

    Do
        With Rng.Find
            .ClearFormatting
            .Replacement.ClearFormatting
            .text = "Keywords ^#"
            .Forward = True
            .Format = True
            .Wrap = wdFindStop
            .MatchWildcards = False
            .Execute
            If Rng.End > selection.range.End Then Exit Do
            If .found Then
                Rng.Paragraphs(1).range.Cut
                Rng.Move unit:=wdParagraph, count:=2
                Rng.Paste
                Rng.Collapse wdCollapseEnd
            Else: Exit Do
            End If
        End With
    Loop
Application.ScreenUpdating = True
Set Rng = Nothing
End Sub
Replace 'Keywords' with your word. If you want to work on the whole doc either press Ctrl+A or replace 'selection.range' with 'ActiveDocument.range'.
Reply With Quote
 

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
1st line of 4-line poem centrally aligned; how to get lines 2-4 to start at same location on page Swarup Word 6 09-16-2022 11:07 AM
Can somebody help me with a macro to move a line two lines down? I need a macro to move dangling words to a new line please iNeedaMacroPlease Word VBA 2 11-27-2020 11:34 AM
How to move a line to another line that starts with a chain selected in the 1st one? gloub Word VBA 24 03-19-2019 03:12 PM
Lock line so text does not move to next line saundrals Word 2 06-19-2014 03:59 PM
Lines move between close and open jsmath22 PowerPoint 0 12-15-2010 07:44 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:49 AM.


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