View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Hello Hello is offline
external usenet poster
 
Posts: 3
Default Error while moving sheet

Hello;
I'm getting Run-time error '9': Subscript out of range
with this code on line with *.
Dim FName As String
FName = BP & "-" & EP & ".xls"
Path = "C:\TS\"
If Not FileExists(FName) Then
ActiveWorkbook.SaveAs FileName:=Path & FName, _
FileFormat:=xlNormal, Password:="++++", WriteResPassword:="++++"
ActiveWorkbook.Close
Else
Workbooks.Open FileName:=Path & FName, Password:="++++",
WriteResPassword:="++++"
ActiveWindow.ActivateNext

* Sheets(1).Move After:=Workbooks(" & FName & ").Sheets(Sheets.Count)

ActiveWorkbook.Close (True)
End If

When I enter actual file name it is fine.
PLease help,
Irek