Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Open CSV File

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!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 420
Default Open CSV File

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
  #3   Report Post  
Posted to microsoft.public.excel.programming
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!!!
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 420
Default Open CSV File

I'd still qualify the range.



On 07/28/2010 12:05, Steve H wrote:
On Jul 28, 10:49 am, Dave 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!!!


--
Dave Peterson
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
Unable to open a 82 KB XLSM file due to "Too many different cellformats" & "Converter failed to open the file." errors. Phillip Pi Excel Discussion (Misc queries) 0 April 23rd 09 08:53 PM
In Excel - Use Windows Explorer instead of File Open to open file KymY Excel Discussion (Misc queries) 1 August 5th 06 09:59 PM
Open a file do a macro ( made) and open next succesive file SVTman74 Excel Programming 5 April 21st 06 10:14 PM
Open File or Switch Between Windows if File is Open Ricky Pang Excel Programming 2 July 8th 05 05:51 AM
Open File or Switch Between Windows if File is Open Ricky Pang Excel Programming 0 July 2nd 05 08:41 PM


All times are GMT +1. The time now is 03:08 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"