Copy sheets based on cell value and paste to a separate excel

Stallios

New Member
Joined
Jul 24, 2020
Messages
2
Office Version
  1. 2010
Platform
  1. Windows
Hi Guys

I have a a few string stored in column A of a excel workbook "Book1"

I want VBA to pick up the names and copy the same named sheets that i have in another excel "Book2" and paste it to book1

Set ListC = Range("C2:C100")
Windows("Book2").Activate
For Each c In ListC

Sheets(c).Copy After:=Workbooks("Book1.xlsm").Sheets(Workbooks("Book1.xlsm").Sheets.Count)
Next c

End Sub
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Hi & welcome to MrExcel.
In what way doesn't your code work?
 
Upvote 0
in modified the code

Sub Button2_Click()
Windows("Book1.xlsm").Activate
Set ListC = Range("C2:C100")

For Each c In ListC

Windows("Book 2").Activate
FormulaString = Replace(c, Chr(126), Chr(34))
Sheets(FormulaString).Activate
Cells.Select
Range("A19").Activate
Selection.Copy
Windows("Book1.xlsm").Activate
Sheets.Add After:=ActiveSheet
ActiveSheet.Paste
Range("J10").Select
Next c

End Sub

getting a run time error
 
Upvote 0
What is the error & which line doe it fail on?
 
Upvote 0

Forum statistics

Threads
1,215,433
Messages
6,124,861
Members
449,195
Latest member
MoonDancer

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