Copy Rows from other Sheet

adelspark

New Member
Joined
Nov 25, 2010
Messages
13
Hello All,

I thought I'd be smart and create a quick recorded macro to select/copy some rows in sheet 'A' and then paste them into sheet 'B' and sort. It wasn't so quick and easy, because it fails at the Rows("6:220").Select line when it runs. Strange, because that's the way it recorded it (see below).

Any thoughts?

Thanks in Advance


Private Sub Worksheet_Activate()
'
Sheets("Grouped Register").Select
Rows("6:220").Select
Selection.Copy
Sheets("Numerical Register").Select
Range("A6").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWorkbook.Worksheets("Numerical Register").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Numerical Register").Sort.SortFields.Add Key:= _
Range("C6:C220"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption _
:=xlSortNormal
With ActiveWorkbook.Worksheets("Numerical Register").Sort
.SetRange Range("B6:N220")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Range("A6").Select
End Sub
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Try:
Code:
Private Sub Worksheet_Activate()
'
Sheets("Grouped Register").Rows("6:220").Copy Destination:=Sheets("Numerical Register").Range("A6")
Application.CutCopyMode = False
ActiveWorkbook.Worksheets("Numerical Register").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Numerical Register").Sort.SortFields.Add Key:= _
Range("C6:C220"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption _
:=xlSortNormal
With ActiveWorkbook.Worksheets("Numerical Register").Sort
.SetRange Range("B6:N220")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Range("A6").Select
End Sub
 
Upvote 0
A big thank you from Australia, Machopicho; you even re-wrote the entire code for me and it works beautifully! I see where I went wrong now.

By the way, that thumbnail photo of me doing 'via ferrata' was taken two months ago only about 100km from Varese. Even more bizarre is that next year we are travelling to Machu Picchu. It's a small but surprising world we live in.

Thanks again ;)
 
Upvote 0

Forum statistics

Threads
1,214,985
Messages
6,122,606
Members
449,089
Latest member
Motoracer88

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