ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Force iteration in workbook (https://www.excelbanter.com/excel-discussion-misc-queries/179452-force-iteration-workbook.html)

gump

Force iteration in workbook
 
I have a workbook that is shared and required iteration to be turned on for
the date calculations to work. How can I force this on everytime the
workbook is opened?

Dave Peterson

Force iteration in workbook
 
You could create a new workbook that changes the calculation mode and then opens
the workbook that you want.

After it's done it's work, the macro would close the new workbook.

Option Explicit
Sub Auto_Open()

Dim TempWkbk As Workbook
Dim Wkbk As Workbook
Dim IsThereAnActiveWork As Boolean

Set TempWkbk = Nothing
On Error Resume Next
Set TempWkbk = ActiveWorkbook
On Error GoTo 0

If TempWkbk Is Nothing Then
IsThereAnActiveWork = False
Set TempWkbk = Workbooks.Add(1)
Else
IsThereAnActiveWork = True
End If

With Application
.Calculation = xlManual
.MaxChange = 0.001
End With

Set Wkbk = Workbooks.Open(Filename:="c:\my documents\excel\book1.xls")

If IsThereAnActiveWork = True Then
'do nothing
Else
TempWkbk.Close savechanges:=False
End If

ThisWorkbook.Close savechanges:=False

End Sub

Then open this helper workbook instead of opening the real workbook.




gump wrote:

I have a workbook that is shared and required iteration to be turned on for
the date calculations to work. How can I force this on everytime the
workbook is opened?


--

Dave Peterson


All times are GMT +1. The time now is 03:27 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com