Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
dan
 
Posts: n/a
Default On Error GoTo skip needs help

"Subscript out of range" appeared when a non existant file was entered,
and the execution was aborted.
Can you help me to continue the execution?

Sub Analyse()
Dim Ans As Variant
Dim filename As String
Sheets("Sheet1").Select
Ans = InputBox(prompt:="Enter the data file name. ")
If Ans = "" Then Exit Sub
filename = Ans & ".csv"
On Error GoTo skip
Workbooks.Open filename:="F:\Cabinet1\" & filename, UpdateLinks:=0
' Main analysis body here
Exit Sub
skip:
Windows("ABC").Activate
Sheets("Sheet1").Range("H1") = Ans & " file does not exist!"
End Sub


  #2   Report Post  
Posted to microsoft.public.excel.misc
Jim Rech
 
Posts: n/a
Default On Error GoTo skip needs help

I'd guess Windows("ABC").Activate is failing. How about
Sheets("Sheet1").Activate instead?

--
Jim
"dan" wrote in message
news:IU63g.200$ud.152@trndny03...
| "Subscript out of range" appeared when a non existant file was entered,
| and the execution was aborted.
| Can you help me to continue the execution?
|
| Sub Analyse()
| Dim Ans As Variant
| Dim filename As String
| Sheets("Sheet1").Select
| Ans = InputBox(prompt:="Enter the data file name. ")
| If Ans = "" Then Exit Sub
| filename = Ans & ".csv"
| On Error GoTo skip
| Workbooks.Open filename:="F:\Cabinet1\" & filename, UpdateLinks:=0
| ' Main analysis body here
| Exit Sub
| skip:
| Windows("ABC").Activate
| Sheets("Sheet1").Range("H1") = Ans & " file does not exist!"
| End Sub
|
|


  #3   Report Post  
Posted to microsoft.public.excel.misc
dan
 
Posts: n/a
Default On Error GoTo skip needs help

Hi, Jim
You are right. It should be Windows("ABC.xls").Activate
Thank you for pointing out.

"Jim Rech" wrote in message
...
I'd guess Windows("ABC").Activate is failing. How about
Sheets("Sheet1").Activate instead?

--
Jim
"dan" wrote in message
news:IU63g.200$ud.152@trndny03...
| "Subscript out of range" appeared when a non existant file was entered,
| and the execution was aborted.
| Can you help me to continue the execution?
|
| Sub Analyse()
| Dim Ans As Variant
| Dim filename As String
| Sheets("Sheet1").Select
| Ans = InputBox(prompt:="Enter the data file name. ")
| If Ans = "" Then Exit Sub
| filename = Ans & ".csv"
| On Error GoTo skip
| Workbooks.Open filename:="F:\Cabinet1\" & filename,
UpdateLinks:=0
| ' Main analysis body here
| Exit Sub
| skip:
| Windows("ABC").Activate
| Sheets("Sheet1").Range("H1") = Ans & " file does not exist!"
| End Sub
|
|




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Skip a cell that contains data slowdiver Excel Worksheet Functions 1 January 22nd 06 02:38 PM
Cond Format:re color 2 cols, skip 2 cols Tat Excel Worksheet Functions 2 June 22nd 05 06:43 PM
How do I skip blank cells when copying over a range of cells? tawells Excel Discussion (Misc queries) 2 June 7th 05 09:36 PM
Even after selecting "skip blanks" in the paste special menu in e. arudra1974 Excel Discussion (Misc queries) 1 February 19th 05 02:59 PM
Skip the holidays Aviator Excel Discussion (Misc queries) 6 January 11th 05 08:13 PM


All times are GMT +1. The time now is 09:43 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"