Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default How to prevent Reopening of target file ?

I have an iteration thus:
For each c in worksheets.

For Each c In Worksheets("Sheet1").Range("A2:A5").Cells
valie = c.Value
If c.Value = 22381 Then
wala = c.Offset(0, 5).Value
If wala = "pills" Then
milla = c.Offset(0, 2).Value

counter = 0
ChDir "C:\milinda"
Workbooks.Open FileName:="C:\milinda\sample-1.xls"
Range("E" & counter + 1).Value = milla
counter = counter + 1
Endif
Endif
Next c


In this, if there are more than 1 occurrence, Excel reminds that the file
Sample-1 is already open, and reopening would reset it. How to prevent it?

Milind


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.504 / Virus Database: 302 - Release Date: 7/24/2003


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default How to prevent Reopening of target file ?

Dim wkbk as workbook
For each c in worksheets.

For Each c In Worksheets("Sheet1").Range("A2:A5").Cells
valie = c.Value
If c.Value = 22381 Then
wala = c.Offset(0, 5).Value
If wala = "pills" Then
milla = c.Offset(0, 2).Value

counter = 0
ChDir "C:\milinda"
set Wkbk = nothing
On error Resume next
set Wkbk = Workbooks("sample-1.xls")
On Error goto 0
if wkbk is nothing then
Workbooks.Open FileName:="C:\milinda\sample-1.xls"
End if
Range("E" & counter + 1).Value = milla
counter = counter + 1
Endif
Endif
Next c

--
Regards,
Tom Ogilvy

Milind wrote in message
...
I have an iteration thus:
For each c in worksheets.

For Each c In Worksheets("Sheet1").Range("A2:A5").Cells
valie = c.Value
If c.Value = 22381 Then
wala = c.Offset(0, 5).Value
If wala = "pills" Then
milla = c.Offset(0, 2).Value

counter = 0
ChDir "C:\milinda"
Workbooks.Open FileName:="C:\milinda\sample-1.xls"
Range("E" & counter + 1).Value = milla
counter = counter + 1
Endif
Endif
Next c


In this, if there are more than 1 occurrence, Excel reminds that the file
Sample-1 is already open, and reopening would reset it. How to prevent it?

Milind


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.504 / Virus Database: 302 - Release Date: 7/24/2003




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
Closing and reopening the same file Tom Excel Discussion (Misc queries) 16 March 11th 09 09:31 PM
Cells widen after saving and reopening file Sigi Rindler Excel Discussion (Misc queries) 2 November 23rd 06 12:03 AM
i zoom to 75% on Excel but returns to 100% reopening file dennis at leapley Excel Worksheet Functions 0 November 17th 06 03:16 PM
Legend box position resetting when reopening file donger Charts and Charting in Excel 0 May 19th 06 08:44 PM
Filter changes upon reopening file! b1 Excel Discussion (Misc queries) 1 December 3rd 04 03:20 AM


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