ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Macro Help Please (https://www.excelbanter.com/excel-discussion-misc-queries/176204-macro-help-please.html)

DT[_2_]

Macro Help Please
 
I am having a problem with the following Macro:



Sub Combine()
Workbooks.Open Filename:="C:\Microsoft Office\Work\Excel\House
Expense.xlsx"
Range("C69:J85").Select
Selection.Copy
Workbooks.Open Filename:="C:\Microsoft Office\Work\Excel\Summary
House.xlsx"
Windows("combined.xlsx").Activate
Worksheets("Sheet1").Select
Range("C6").Select
ActiveSheet.Paste
End Sub

The lines dealing with opening a File name do not go to a second line

On the line: Windows("combined.xlsx").Activate

I receive an error: Run-time error '9': Subscript out of range.

I cannot figure this out.

Appreciate any help.

Thanks, Dave

JMB

Macro Help Please
 
The macro is expecting you have a workbook named combined.xlsx that is
already open.

If you are trying to copy information into combined.xlsx, why open the
summary workbook? If you are trying to copy info into the summary workbook,
I think you should remove the Windows("combined.xlsx").Activate statement.


"DT" wrote:

I am having a problem with the following Macro:



Sub Combine()
Workbooks.Open Filename:="C:\Microsoft Office\Work\Excel\House
Expense.xlsx"
Range("C69:J85").Select
Selection.Copy
Workbooks.Open Filename:="C:\Microsoft Office\Work\Excel\Summary
House.xlsx"
Windows("combined.xlsx").Activate
Worksheets("Sheet1").Select
Range("C6").Select
ActiveSheet.Paste
End Sub

The lines dealing with opening a File name do not go to a second line

On the line: Windows("combined.xlsx").Activate

I receive an error: Run-time error '9': Subscript out of range.

I cannot figure this out.

Appreciate any help.

Thanks, Dave


paul[_2_]

Macro Help Please
 
as stated above,if you are copying from "combined" to "house" you need to
have combined open too.The windows.activate command basically is toggling
from one work book or worksheet to the other
--
paul

remove nospam for email addy!



"JMB" wrote:

The macro is expecting you have a workbook named combined.xlsx that is
already open.

If you are trying to copy information into combined.xlsx, why open the
summary workbook? If you are trying to copy info into the summary workbook,
I think you should remove the Windows("combined.xlsx").Activate statement.


"DT" wrote:

I am having a problem with the following Macro:



Sub Combine()
Workbooks.Open Filename:="C:\Microsoft Office\Work\Excel\House
Expense.xlsx"
Range("C69:J85").Select
Selection.Copy
Workbooks.Open Filename:="C:\Microsoft Office\Work\Excel\Summary
House.xlsx"
Windows("combined.xlsx").Activate
Worksheets("Sheet1").Select
Range("C6").Select
ActiveSheet.Paste
End Sub

The lines dealing with opening a File name do not go to a second line

On the line: Windows("combined.xlsx").Activate

I receive an error: Run-time error '9': Subscript out of range.

I cannot figure this out.

Appreciate any help.

Thanks, Dave


DT[_2_]

Macro Help Please
 
On Sat, 9 Feb 2008 14:19:01 -0800, paul
wrote:

as stated above,if you are copying from "combined" to "house" you need to
have combined open too.The windows.activate command basically is toggling
from one work book or worksheet to the other



All is well thank you both for the help. I always worked with Lotus
and I am trying to learn Excel.

Dave


All times are GMT +1. The time now is 05:12 AM.

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