ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   annoying subscript out of range error (https://www.excelbanter.com/excel-programming/412482-annoying-subscript-out-range-error.html)

PBcorn

annoying subscript out of range error
 
there's somehting wrong with the syntax of the following but i cant work out
what:

With Workbooks("G:\MI Report\Source Tables-DIR-Producers\Source Table -
Merge Template - Direct.xls")

.MergeWorkbook ("G:\MI Report\Source Tables-DIR-Producers\Source
Table-DIR-Producer JL.AP.xls")
.MergeWorkbook ("G:\MI Report\Source Tables-DIR-Producers\Source
Table-DIR-Producer SK.CG.xls")
.MergeWorkbook ("G:\MI Report\Source Tables-DIR-Producers\Source
Table-DIR-Producer ZB.KP.xls")

For Each sh In .Worksheets

sh.Visible = True
sh.Columns.EntireColumn.Hidden = False

Next sh

End With

error seems to be due to the full path ref.

i've tried taking out .xls but this makes no difference

please help

joel

annoying subscript out of range error
 
The with workbooks statement shouldn't have the Folder name, just the
basename of the file. Try this code.

Folder = "G:\MI Report\Source Tables-DIR-Producers\"
With Workbooks("Source Table - Merge Template - Direct.xls")

.MergeWorkbook (Folder & "Source Table-DIR-Producer JL.AP.xls")
.MergeWorkbook (Folder & "Source Table-DIR-Producer SK.CG.xls")
.MergeWorkbook (Folder & "Source Table-DIR-Producer ZB.KP.xls")

For Each sh In .Worksheets

sh.Visible = True
sh.Columns.EntireColumn.Hidden = False

Next sh

End With


"PBcorn" wrote:

there's somehting wrong with the syntax of the following but i cant work out
what:

With Workbooks("G:\MI Report\Source Tables-DIR-Producers\Source Table -
Merge Template - Direct.xls")

.MergeWorkbook ("G:\MI Report\Source Tables-DIR-Producers\Source
Table-DIR-Producer JL.AP.xls")
.MergeWorkbook ("G:\MI Report\Source Tables-DIR-Producers\Source
Table-DIR-Producer SK.CG.xls")
.MergeWorkbook ("G:\MI Report\Source Tables-DIR-Producers\Source
Table-DIR-Producer ZB.KP.xls")

For Each sh In .Worksheets

sh.Visible = True
sh.Columns.EntireColumn.Hidden = False

Next sh

End With

error seems to be due to the full path ref.

i've tried taking out .xls but this makes no difference

please help



All times are GMT +1. The time now is 02:31 PM.

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