Thread: Open CSV File
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Steve H[_2_] Steve H[_2_] is offline
external usenet poster
 
Posts: 5
Default Open CSV File

On Jul 28, 10:49*am, Dave Peterson wrote:
My first guess would be that the code is in a worksheet module.

If that's true, then the unqualified range (Range("F2")) refers to the sheet
that owns the code -- not the activesheet.

If the code is in a General module, then this isn't a good guess. *The
unqualified range should refer to the activesheet.

In either case, I'd qualify that range.

Set mybook = Workbooks.Open(MyPath & MyFiles(Fnum))
mybook.worksheets(1).Range("F2").Formula _
* = "=SUMPRODUCT(--($e$3:$e$500=""Dog""),roundup(1.02*(f$3:f$500),0)) "

I've never seen a situation where qualifying the range is a bad idea!

On 07/28/2010 07:29, Steve H wrote:

I am using Set mybook = Workbooks.Open(MyPath& *MyFiles(Fnum)) to open
a csv file. After the file is opened I would like to make changes to
the file. *The code is stored in another file Basebook. *The code
works fine for opening the file and it appears that mybook is the
active book. *However the changes that I make are being made to
Basebook and not mybook. *The code works flawlessly in another
instance opening a different file, so it appears as though there may
be some problem with the file.


Set mybook = Workbooks.Open(MyPath& *MyFiles(Fnum))
Range("F2").Formula = "=SUMPRODUCT(--($e$3:$e
$500=""Dog""),roundup(1.02*(f$3:f$500),0))"


Any ideas?
Thanks!


--
Dave Peterson


Yes that was it. I changed it to a General Module and it is working
now.
Thanks!!!