copy data from workbook1 to workbook2

pwill

Active Member
Joined
Nov 22, 2015
Messages
406
Hi can anyone help with a line of code to copy data from

workbook1 sheet1 range ("A:AS") to
workbook2 sheet1 range ("A:AS")

Regards

pwill
 
Thanks My Aswer Is This, I was trying both and getting the same error, I knew I was missimg something, can't believe I didn't notice that? lol

Thank you both for your help much apprieciated

Regards

pwill
 
Upvote 0

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Just to let you know you can refer to sheets in two different ways like:

Sheets(1)
Sheets(2)

Now Sheets(1) is the sheet in the far left position on your tab bar
Now Sheets(2) is the next sheet to the right and so on.

And the second way to refer to sheets is by their name like:
Sheets("Sheet1") Or Sheets("Sheet2")

Or:
Sheets("George") Or Sheets("Home")

If you use the name of the sheet then name has to be in quotes.
Just thought you may want to know.



 
Upvote 0
Yes always apprieciate any help you can give, thanks My Aswer Is This :)

Just one question, I have numbered my sheets (01) instead of (1) so they run in order as I have more than 10 sheets.

When I try to refer to sheets as Sheets(01) it won't accept the 0 and changes back to Sheets(1) does this make a difference or effect the code in any way?

regards

pwill
 
Last edited:
Upvote 0
Your not able to renumber your sheets.

Sheets(1) is the sheet on the far left side of the tab bar no matter what you name it.

Explain more about "you" want to run them in order"

You can rename your sheets

If you mean you want to loop through your sheets it would look like this

For i= 1 to Sheets.count

Sheets.count means last sheet.

So the loop from go from 1 to last sheet.


Does that help?
 
Upvote 0
If you mean you want to reorder them on your Tab Bar then:
1. Click on the Tab and drag it to the right or left.
That will now change their order.
One on far left is 1 next one to right is 2 and so on.
 
Last edited:
Upvote 0
You should be able to get 01 to appear on the sheet name tab, but when referring to it in code you would have to use Sheets("01"), with the numeric digits enclosed in quote marks. While the tab name appears as numbers, it is a string data type and all string data will generally need quote marks when used in code, unless you put them in variables. Variables do not use quote marks, but may represent data which does use quote marks. The bit about the variables is just additional info, not to be confused with the explanation of using the 01 in code.
 
Last edited:
Upvote 0
Hi, Thank you for your input,

Sorry, I should have said it was in the vba editor project window I was refering to where I have renumbered my sheets.
For example I have over 10 sheets, on the first sheet I have named the Tab Bar as Data and in the vba project window I have renamed to Sheet01(Data) instead of Sheet1(Data) and Shet02(Sort) instead of Sheet2 and so on.
So they all run in order in the project window with Sheet 10 and above at the bottom of the list.

There is no problem as such,

I was just wondering why when I try to refer to sheets as Sheets(01) it won't accept the 0 and changes back to Sheets(1)? does this make a difference or effect the code in any way?

Regards

pwill
 
Last edited:
Upvote 0
Your not able to renumber your sheets.

Sheets(1) is the sheet on the far left side of the tab bar no matter what you name it.

Explain more about "you" want to run them in order"

You can rename your sheets

If you mean you want to loop through your sheets it would look like this

For i= 1 to Sheets.count

Sheets.count means last sheet.

So the loop from go from 1 to last sheet.


Does that help?



Hi,

I am trying to write my own code for the first time and I am trying to use the 'For i=' in the code to help me understand how it works and wondered if I give an example of what I am trying to do and post it tomorrow as I am off out to the cinema tonight to watch Jamanji, if you might be able to help with this?

Regards

pwill
 
Upvote 0

Forum statistics

Threads
1,215,097
Messages
6,123,076
Members
449,094
Latest member
mystic19

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