Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Data1 are the sheets to be copied from different files.
Combine sheet is the master sheet, where the data in data1 sheets are to be copied. I get an error "subscript out of range" ?? correct the following code please. For N = LBound(FName) To UBound(FName) Set mybook = Workbooks.Open(FName(N)) Set sourceRange = mybook.Worksheets("DATA1").Range("A4:S200") SourceRcount = sourceRange.Rows.Count Set destrange = basebook.Worksheets("COMBINE SHEET").Cells(rnum, "A") basebook.Worksheets("COMBINE SHEET").Cells(rnum, "G").Value = mybook.Name ' This will add the workbook name in column D if you want sourceRange.Copy destrange ' Instead of this line you can use the code below to copy only the Values ' With sourceRange ' Set destrange = basebook.Worksheets(1).Cells(rnum,"A"). _ ' Resize(.Rows.Count, .Columns.Count) ' End With ' destrange.Value = sourceRange.Value mybook.Close False rnum = rnum + SourceRcount Next |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Error:Subscript out of range | Excel Discussion (Misc queries) | |||
Subscript out of range (Error 9) | Excel Programming | |||
Type Mismatch error & subscript out of range error | Excel Programming | |||
Subscript Out Of Range Error? | Excel Programming | |||
Subscript out of range error | Excel Programming |