Copy & Paste 'Database' Then Set Array

darkdimension

New Member
Joined
May 30, 2010
Messages
20
The following code does not allow the 'CurrentRegion' to be selected and 'Set'. I believe it has to do with the pasting does not retain focus of the table that 'Database' creates.


Range("Database").Copy

Range("A2800").PasteSpecial Paste:=xlValues, _
Operation:=xlNone, SkipBlanks:=False, Transpose:=False

'Selection.Sort Key1:=Range("M2801"), Order1:=xlAscending, _
Header:=xlYes, OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom

Set Itemlist = Selection.CurrentRegion

If I sort (ie, remove comment) the list before I try to 'Set', all is fine.

How do I gain focus and set the 'Database' table to the array?

Thank you in advance.
 
Last edited:

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Try changing Selection to Range("A2800").
 
Upvote 0
Thank you for the response.

Made the change. It does not appear to be selecting the region.

Code:
     Range("Database").Copy
        
     Range("A2800").PasteSpecial Paste:=xlValues, _
                   Operation:=xlNone, SkipBlanks:=False, Transpose:=False

     'Selection.Sort Key1:=Range("M2801"), Order1:=xlAscending, _
        Header:=xlYes, OrderCustom:=1, MatchCase:=False, _
        Orientation:=xlTopToBottom

      Set Itemlist = Range("A2800").CurrentRegion
 
Upvote 0
Problem resolved...the region was not contiguous. Ugh, missed the obvious.

Thanks for the response, Norie and all that viewed.
 
Upvote 0

Forum statistics

Threads
1,216,101
Messages
6,128,844
Members
449,471
Latest member
lachbee

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