Opening a csv file stops macro

P

Prema

In vb I have code to open a csv file. After opening the file "YY" is entered
in cell A1 and macro stops. But if I introduce a breakpoint at open file
statement code and step it thru Mcro continues OK. I have no idea where "YY"
is coming from. Can anyone say how this can be resolved without having to set
break point and step thru as this will be used by end users who will find it
confusing.

Thank you
 
M

Matt Richardson

In vb I have code to open a csv file. After opening the file "YY" is entered
in cell A1 and macro stops. But if I introduce a breakpoint at open file
statement code and step it thru Mcro continues OK. I have no idea where "YY"
is coming from. Can anyone say how this can be resolved without having to set
break point and step thru as this will be used by end users who will find it
confusing.

Thank you

Could you send us a sample of the code so that we can identify the
problem?

Regards,
Matt Richardson
http://teachr.blogspot.com
 
P

Prema

I have copied code starting just before the open statement and after. It
opens the file, puts "YY" in cell A! and stops.

Range("A3").Select
Selection.Sort Key1:=Range("A2"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Range("A2").Select

' Open Argos asisit outstanding file and format columns
Workbooks.Open
Filename:="\\gbrcrotpc5ms011\sod$\SAPData\Argos-ASIST-outstanding.csv"
Rows("1:3").Select
Selection.Delete Shift:=xlUp
Range("D3").Select
 
D

Dave Peterson

How do you start your macro?

Do you use a shortcut key? Does that shortcut key include the shiftkey?

Does the problem go away if you drop the shift from the shortcut key
combination?

If you have a workbook that has a workbook_open event or an auto_open procedure,
then if you open that file with the shift key held down, you stop those
procedures from running.

The shift-key in the shortcut combination confuses excel/vba to stop after you
open a file using one of those shortcut keys.
 
P

Prema

Macro is started by pressing a button on the workbook. it opens many files
but this is the only one it seem to be hanging. It used to work OK before but
suddenly started this problem. This file is saved from a third party website.
Could any changes in the properties of the file cause the problem?

Prema
 
N

Nigel

You bet! I would start looking at the file you are trying to load first.
Normally whenever I hear "Well it was working OK, then it just stopped" it
more often than not is something outside of your control, a third party file
is highly likely to be the culprit.

--

Regards,
Nigel
(e-mail address removed)
 
D

Dave Peterson

Try opening the .csv file in notepad to see if something doesn't look right.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top