Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
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
Posted to microsoft.public.excel.misc
|
|||
|
|||
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
Posted to microsoft.public.excel.misc
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Skip a cell that contains data | Excel Worksheet Functions | |||
Cond Format:re color 2 cols, skip 2 cols | Excel Worksheet Functions | |||
How do I skip blank cells when copying over a range of cells? | Excel Discussion (Misc queries) | |||
Even after selecting "skip blanks" in the paste special menu in e. | Excel Discussion (Misc queries) | |||
Skip the holidays | Excel Discussion (Misc queries) |