Moving data down or up to row 10

tonywatsonhelp

Well-known Member
Joined
Feb 24, 2014
Messages
3,194
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
Hi Everyone,
I have the need for a macro that will goto to the active sheet,
look down column A
Find the cell that contains the word "Time" (this is the entire contents)
then move everything up or down so "Time" is in column A

So a few rule that might help,
Column A will Always Have the last row of data,
The data is in column A:DZ
only one cell in Column A will hold the Word "Time"
Moving the data is only everything from the "Time" row down, Time should be the very first row and can be any row in the sheet

thanks

Tony
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Test on a COPY of your data
- your explanation is not complete

is this what you want

VBA Code:
Sub MoveData()
    Dim FoundRow As Long, MoveToRow As Long: MoveToRow = 10
   
    On Error GoTo TheEnd
        FoundRow = Range("A:A").Find("Time", LookIn:=xlValues, lookat:=xlWhole).Row
    On Error GoTo 0

    If MoveToRow > FoundRow Then MoveToRow = MoveToRow + 1
    If MoveToRow <> FoundRow Then
        Rows(FoundRow).Cut
        Rows(MoveToRow).Select
        Selection.Insert Shift:=xlDown
        Range("A" & MoveToRow).Select
    End If

Exit Sub
TheEnd:
    MsgBox "Not found", vbExclamation, "oops"
End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,214,936
Messages
6,122,340
Members
449,079
Latest member
rocketslinger

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top