macro to move row up and down

Status
Not open for further replies.

wizmaster

New Member
Joined
May 16, 2013
Messages
12
I'm using this macro to help me move a row of data in excel up one row. When i use autofilter and have columns hidden, it is not moving the hidden columns - just the columns that is not hidden. however when i do not have any autofilter, it is moving the full row (including the hidden rows). Any ideas on how to fix this? I wonder if the Activecell.row is the right logic to use here?


VBA Code:
sub upwards

Dim tmp As Long


tmp = 5000
If ActiveCell.Row <> Rows.Count And ActiveCell.Row > 2 Then
    Cells(ActiveCell.Row + 1, 1).EntireRow.Copy Cells(tmp, 1)
    ActiveCell.EntireRow.Copy Cells(ActiveCell.Row + 1, 1)
    Cells(tmp, 1).EntireRow.Copy Cells(ActiveCell.Row, 1)
    ActiveCell.Offset(1, 0).EntireRow.Select
End If
End Sub

End Sub
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Duplicate to: Excel Table, move rows up

In future, please do not post the same question multiple times. Per Forum Rules (#12), posts of a duplicate nature will be locked or deleted.

In relation to your question here, I have closed this thread so please continue in the linked thread.
 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,214,992
Messages
6,122,631
Members
449,095
Latest member
bsb1122

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