VBA code to copy specific range

Alteran

Board Regular
Joined
Nov 25, 2009
Messages
117
I am trying to get VBA to allow me to select a specific range of cells to copy, however it keeps giving me an error when I do the range select, I have tried this two different ways and still get the same issue can anyone help me out with this?

#1:
Code:
        'Select the data wanted
        Sheets("Combined Data").Select
        Range("A3:BN3").Select
            'Copies the Data
            Selection.Copy
                'Back to original Sheet
                Sheets("Administration").Select

#2
Code:
        'Select the data wanted
        Worksheets("Data2").Range("A3:BN3").Select
            'Copies the Data
            Selection.Copy
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
There's no need to select anything

Code:
Worksheets("Data2").Range("A3:BN3").Copy
 

Weaver

Well-known Member
Joined
Sep 10, 2008
Messages
5,196
There's no need to select the data first

Code:
Worksheets("Data2").Range("A3:BN3").Copy
Which might be the answer if Data2 isn't the currently active sheet.
 

Alteran

Board Regular
Joined
Nov 25, 2009
Messages
117
Doh! yeah that worked Thanks VoG... its just to early in the morning for me I guess!
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,015
Messages
5,834,939
Members
430,327
Latest member
Mr_Himalayan778

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
Top