Get Row, Cut and Insert

I recorded this and it uses row 11.  How do I do the samething but only on the row of the ActiveCell?  and make sure that only one cell is selected and not a range of rows?

    Rows("11:11").Select
    Range("B11").Activate
    Selection.Cut
    Rows("7:7").Select
    Range("B7").Activate
    Selection.Insert Shift:=xlDown

Open in new window

RWayneHAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

DougCommented:
When you say "do the same thing" do you mean cut from the active cell and then insert the cell into B7 and shift down? Is this what you're trying to do?

    ActiveCell.Cut
    Range("B7").Activate
    ActiveCell.Insert xlShiftDown

Open in new window

RWayneHAuthor Commented:
No cut the whole row of the activecell, not the cell only.  So if in active cell is h23.  Cut row 23 and insert it at row 7 (move it to the top), shifting it all down.
DougCommented:
Ok. Try this.

    ActiveCell.EntireRow.Cut
    Range("7:7").EntireRow.Insert

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

RWayneHAuthor Commented:
How about if I wanted to paste it into row 7 instead of inserting it?   .Paste did not work.
DougCommented:
Okay, that's a new question : )

Did the code in my previous comment answer this question?

"No cut the whole row of the activecell, not the cell only.  So if in active cell is h23.  Cut row 23 and insert it at row 7 (move it to the top), shifting it all down. "

For the pasting question, do you want to delete the row that you want to  paste in row 7?
RWayneHAuthor Commented:
Yes delete the old row.  Just moving the row to the top of the list.  A different procedure happens to add a blank row at the top of the list.  Yes suppose it is another simular question.
Saurabh Singh TeotiaCommented:
Wayne,

Here are two methods to do the same..

Method-1:-

Sub mverws()
ActiveCell.EntireRow.Copy Range("a7")
ActiveCell.EntireRow.Delete

End Sub

Open in new window


Method-2:-

Sub mverws1()

ActiveCell.EntireRow.Cut
Range("a7").Select
ActiveSheet.Paste
Range("a7").Select


End Sub

Open in new window


Saurabh...
DougCommented:
Ok, the following will address your second request. Note that this will affect only the current region which means that if you have information on the same row but to the right of your table and not related to that table, that information will not be deleted.

Sub CopyRws()

Dim rng As Range
Dim intCols As Integer
Dim introw As Integer

Set rng = ActiveCell.CurrentRegion
intCols = rng.Columns.Count
introw = ActiveCell.Row

Range(Cells(introw, 1), Cells(introw, intCols)).Copy

Range("A7").PasteSpecial xlPasteAll

Range(Cells(introw, 1), Cells(introw, intCols)).Delete xlShiftUp

Set rng = Nothing

End Sub

Open in new window

RWayneHAuthor Commented:
Split the points, both great solutions..  sorry for the delay in responding.  Appreciate the help.
DougCommented:
Great! Always glad to help. Thanks for the points!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.