Copy a sheet from a specific workbook with VBA

Bryniac

New Member
Joined
Oct 28, 2013
Messages
14
What i need is to copy a specific worksheet at the current workbook i'm working, I know that i can use move or copy tool but i want to do a macro and add it to and excel add-in, i tried this code and it works, the thing is that it should be executed from the workbook where i want to paste the sheet. the code doesn't work when i put it on an excel add-in. :confused:


Code:
Sub GetSheets()
Path = "C:\Users\OutsourcingSOS\Dropbox\List Build Queue\Don't open this folder\"
Filename = Dir(Path & "*.xls")
Do While Filename <> ""
Workbooks.Open Filename:=Path & Filename, ReadOnly:=True
For Each Sheet In ActiveWorkbook.Sheets
Sheet.Copy After:=ThisWorkbook.Sheets(1)
Next Sheet
Workbooks(Filename).Close
Filename = Dir()
Loop
End Sub

So to make it clear the excel book with the worksheet that i want to paste is always located at the same folder, what i want is to bring a copy of that sheet to the current book that i'm working. :p

(code above works, it can bring ALL the worksheets from ALL the workbooks in a specific folder to one single workbook)
but i want it within an add-in.

please, i need some ideas

Thanks in advance. :biggrin:
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
yeah, I know how it works, the things is that I don't like the PERSONAL macro workbook (PMW), 'cause the first time I open a workbook the PMW is also opened by itself (sometimes is annoying)... that's why i wanted to added it to and add-in.

Anyway thanks for take some time to answer to my thread. :)
 
Upvote 0

Forum statistics

Threads
1,215,048
Messages
6,122,862
Members
449,097
Latest member
dbomb1414

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