View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
hawki hawki is offline
external usenet poster
 
Posts: 27
Default number of workbooks less 1

Followng is the complete code which stops at the line below with an error
code of "9" subscript out of range.

Workbooks("info").Worksheets("info").Range("a1").E nd(xlDown).Offset(1,
0).PasteSpecial xlPasteValues


Sub test2()
Dim lngCount As Long
Dim Number As Long
Number = Workbooks.Count
For lngCount = 1 To Number
If Not Workbooks(lngCount).Name = "info" Then
Workbooks(lngCount).Worksheets(1).Range("b1:b5").C opy
Workbooks("info").Worksheets("info").Range("a1").E nd(xlDown).Offset(1,
0).PasteSpecial xlPasteValues
Workbooks(lngCount).Close savechanges:=False
End If
Next lngCount
Workbooks("info.xls").Close savechanges:=True
End Sub

--
l-hawk


"Jim Cone" wrote:


If you do not use an index number to identify a specific workbook or
worksheet then you must use the name of the workbook or worksheet.
All names are strings except for those referring to range objects,
so enclose info in quotation marks...
Worksheets("info")
'--
Jim Cone


"hawki"
wrote in message
I get the following error. Run time error "9". Subscript out of range.
--
l-hawk


"Jim Cone" wrote:
And what is the error you get?
Jim Cone



"hawki"
wrote in message
The procedure stops at the following line.

Workbooks("info.xls").Worksheets(info).Range("a1") .End(xlDown).Offset(1,
0).PasteSpecial xlPasteValues
--
l-hawk