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 change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
There's no need to select anything

Code:
Worksheets("Data2").Range("A3:BN3").Copy
 
Upvote 0
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.
 
Upvote 0

Forum statistics

Threads
1,224,537
Messages
6,179,405
Members
452,911
Latest member
a_barila

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