ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Combing Workbooks (https://www.excelbanter.com/excel-programming/313975-combing-workbooks.html)

GazMo[_6_]

Combing Workbooks
 

It falls over in this section of your code ...

For Each wks In CustWkbk.Worksheets
With wks
Set newWks = CombWkbk.Worksheets.Add
newWks.Name = .Name
Set destCell = newWks.Range("a1")

Do both worksheets need to be open when the macro is run or can I pu
the whole file path in, as i need a button in one of the workbooks t
run this macro

--
GazM
-----------------------------------------------------------------------
GazMo's Profile: http://www.excelforum.com/member.php...fo&userid=1461
View this thread: http://www.excelforum.com/showthread.php?threadid=27024


Dave Peterson[_3_]

Combing Workbooks
 
Both workbooks need to be open.

And if it still fails, make sure you indicate which line in that section fails.

Or you can open the other workbook in code.

set custwkbk = workbooks.open(Filename:="c:\your path\customer.xls")



GazMo wrote:

It falls over in this section of your code ...

For Each wks In CustWkbk.Worksheets
With wks
Set newWks = CombWkbk.Worksheets.Add
newWks.Name = .Name
Set destCell = newWks.Range("a1")

Do both worksheets need to be open when the macro is run or can I put
the whole file path in, as i need a button in one of the workbooks to
run this macro?

--
GazMo
------------------------------------------------------------------------
GazMo's Profile: http://www.excelforum.com/member.php...o&userid=14610
View this thread: http://www.excelforum.com/showthread...hreadid=270243


--

Dave Peterson



All times are GMT +1. The time now is 11:13 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com