LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Workbook_Open() won't run macro unless breakpoint set

I have this macro/code placed in "ThisWorkbook" in the VBAPProject of a 2003
excel file. The problem is it is not clearing the scroll area when the
reference field is set to "No"

Private Sub Workbook_Open()
If Worksheets("Data").Range("I16").Value = "Yes" Then
Application.CommandBars("Worksheet Menu
Bar").FindControl(ID:=30006).Enabled = False
Application.CommandBars("Worksheet Menu
Bar").FindControl(ID:=30007).Enabled = False
Application.CommandBars("Ply").FindControl(ID:=889 ).Enabled = False
Application.CommandBars("Ply").FindControl(ID:=156 1).Enabled = False
Sheets("Sales").Select
Dim LastRow As Long
With Worksheets("Sales")
LastRow = .Cells(.Rows.Count, "B").End(xlUp).Row
.ScrollArea = "B2:C" & LastRow
End With
ElseIf Worksheets("Data").Range("I16").Value = "No" Then
Application.CommandBars("Worksheet Menu
Bar").FindControl(ID:=30006).Enabled = True
Application.CommandBars("Worksheet Menu
Bar").FindControl(ID:=30007).Enabled = True
Application.CommandBars("Ply").FindControl(ID:=889 ).Enabled = True
Application.CommandBars("Ply").FindControl(ID:=156 1).Enabled = True
Sheets("Sales").Select
ActiveSheet.ScrollArea = ""
End If
End Sub

It acts like it will not run the macro on opening the file. If I place a
breakpoint anywhere within that routine, on open it opens the vba editor and
I can step/run thru the procedure and the worksheet is fine. Meaning the
scroll area restriction for the sales sheet has been eliminated when the
reference field is set to "No". But if vba is not triggered to open it acts
like it just skips the running of the macro and never tests the Yes/No
condition.

The referenced cell "i16" is populated with a "No" and formatted to text.
It was formatted as date and I thought maybe that was messing it up, but
after changing it to text and general it still would not fire on opening.

I had been setting the scroll area by running a macro, but decided to
include it in the workbook open, I thought it would handle it better and keep
the rest of the module cleaner.

If you see the obvious problem with this please let me know, I have stared
at it for hours and cannot see the problem. If you need the whole module
code I have pieced together, I am more than happy to paste the whole ugly
thing out here for you to review to see if I am running contradictory code
somewhere else in my procedures.

Any help or ideas on how to fix this or change it to make it work correctly
will be greatly appreciated. I am getting better at Macros and where to
place the code, but am still green when it comes to all things VB, so don't
assume I know too much.

Thanks,

Martin

Sorry for the long posting :)
 
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
Ignore breakpoint when running a macro hmm Excel Programming 5 January 1st 08 12:51 PM
breakpoint affecting the run speed of a macro kebabb Excel Programming 3 December 2nd 06 05:17 AM
Macro runs upon wkbk open, but no Workbook_Open or Auto_Open Macro Ron Coderre Excel Programming 2 September 26th 06 05:50 PM
Breakpoint ok, no breakpoint messes up... Vikxcel[_8_] Excel Programming 0 January 4th 06 09:18 PM
How to insert a breakpoint and run the Workbook_Open event ?? Charles Jordan Excel Programming 5 March 6th 05 09:12 AM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"