Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Unable to open a 82 KB XLSM file due to "Too many different cellformats" & "Converter failed to open the file." errors. | Excel Discussion (Misc queries) | |||
In Excel - Use Windows Explorer instead of File Open to open file | Excel Discussion (Misc queries) | |||
Open a file do a macro ( made) and open next succesive file | Excel Programming | |||
Open File or Switch Between Windows if File is Open | Excel Programming | |||
Open File or Switch Between Windows if File is Open | Excel Programming |