Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
cdavidson
 
Posts: n/a
Default Help with 'Auto_Open' please...

SubThe first time I open my excel workbook, a macro automatically runs. Part
of this macro eventually calls for the deleting of 'Sheet1' in the workbook.
When the macro is finished running, I save the file.

The second time I open the workbook, I want it to check to see if it
contains a 'Sheet1'. If it does, 'Exit Sub', else do something else...

I've pasted my VBA code below. Do you see anything wrong with it?

Many thanks,

Craig

----------------------------------

Private Sub Auto_Open()

calcmod = Application.Calculation

With Application
.Calculation = xlManual
.MaxChange = 0.001
.CalculateBeforeSave = False
End With
ActiveWorkbook.PrecisionAsDisplayed = False


On Error Resume Next

Set sht = Sheets("Sheet1")
If sht Is Nothing Then

Exit Sub

Else

Macro
Application.Calculation = calcmod

End If

On Error GoTo 0

End
  #2   Report Post  
Chip Pearson
 
Posts: n/a
Default Help with 'Auto_Open' please...

What specific problem are you having?


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"cdavidson" wrote in
message
...
SubThe first time I open my excel workbook, a macro
automatically runs. Part
of this macro eventually calls for the deleting of 'Sheet1' in
the workbook.
When the macro is finished running, I save the file.

The second time I open the workbook, I want it to check to see
if it
contains a 'Sheet1'. If it does, 'Exit Sub', else do something
else...

I've pasted my VBA code below. Do you see anything wrong with
it?

Many thanks,

Craig

----------------------------------

Private Sub Auto_Open()

calcmod = Application.Calculation

With Application
.Calculation = xlManual
.MaxChange = 0.001
.CalculateBeforeSave = False
End With
ActiveWorkbook.PrecisionAsDisplayed = False


On Error Resume Next

Set sht = Sheets("Sheet1")
If sht Is Nothing Then

Exit Sub

Else

Macro
Application.Calculation = calcmod

End If

On Error GoTo 0

End



  #3   Report Post  
cdavidson
 
Posts: n/a
Default Help with 'Auto_Open' please...

Hi Chip:

My excel file is actually handled by a trid party application, so I can't
watch the macros run. I believe a line of code I have which is supposed to
delete Sheet1 first time through, isn't working correctly becauise the entire
macro runs again when I open the file a second time. I realize it's the
'Delete Sheet1' area of code I probably need to focus on, but first wanted to
make sure the 'auto_Open' code looked good.

If you can't see any serious mistakes in my 'Auto_Open' sub???, then I'll
move on to troubleshooting why the third party app isn't allowing my macro to
delete Sheet1 the first time it runs.

Thanks,



"Chip Pearson" wrote:

What specific problem are you having?


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"cdavidson" wrote in
message
...
SubThe first time I open my excel workbook, a macro
automatically runs. Part
of this macro eventually calls for the deleting of 'Sheet1' in
the workbook.
When the macro is finished running, I save the file.

The second time I open the workbook, I want it to check to see
if it
contains a 'Sheet1'. If it does, 'Exit Sub', else do something
else...

I've pasted my VBA code below. Do you see anything wrong with
it?

Many thanks,

Craig

----------------------------------

Private Sub Auto_Open()

calcmod = Application.Calculation

With Application
.Calculation = xlManual
.MaxChange = 0.001
.CalculateBeforeSave = False
End With
ActiveWorkbook.PrecisionAsDisplayed = False


On Error Resume Next

Set sht = Sheets("Sheet1")
If sht Is Nothing Then

Exit Sub

Else

Macro
Application.Calculation = calcmod

End If

On Error GoTo 0

End




  #4   Report Post  
Chip Pearson
 
Posts: n/a
Default Help with 'Auto_Open' please...

I don't see any problems with your Auto_Open macro.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"cdavidson" wrote in
message
...
Hi Chip:

My excel file is actually handled by a trid party application,
so I can't
watch the macros run. I believe a line of code I have which is
supposed to
delete Sheet1 first time through, isn't working correctly
becauise the entire
macro runs again when I open the file a second time. I realize
it's the
'Delete Sheet1' area of code I probably need to focus on, but
first wanted to
make sure the 'auto_Open' code looked good.

If you can't see any serious mistakes in my 'Auto_Open' sub???,
then I'll
move on to troubleshooting why the third party app isn't
allowing my macro to
delete Sheet1 the first time it runs.

Thanks,



"Chip Pearson" wrote:

What specific problem are you having?


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"cdavidson" wrote in
message
...
SubThe first time I open my excel workbook, a macro
automatically runs. Part
of this macro eventually calls for the deleting of 'Sheet1'
in
the workbook.
When the macro is finished running, I save the file.

The second time I open the workbook, I want it to check to
see
if it
contains a 'Sheet1'. If it does, 'Exit Sub', else do
something
else...

I've pasted my VBA code below. Do you see anything wrong
with
it?

Many thanks,

Craig

----------------------------------

Private Sub Auto_Open()

calcmod = Application.Calculation

With Application
.Calculation = xlManual
.MaxChange = 0.001
.CalculateBeforeSave = False
End With
ActiveWorkbook.PrecisionAsDisplayed = False


On Error Resume Next

Set sht = Sheets("Sheet1")
If sht Is Nothing Then

Exit Sub

Else

Macro
Application.Calculation = calcmod

End If

On Error GoTo 0

End






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



All times are GMT +1. The time now is 08:06 PM.

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"