Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Ignore breakpoint when running a macro | Excel Programming | |||
breakpoint affecting the run speed of a macro | Excel Programming | |||
Macro runs upon wkbk open, but no Workbook_Open or Auto_Open Macro | Excel Programming | |||
Breakpoint ok, no breakpoint messes up... | Excel Programming | |||
How to insert a breakpoint and run the Workbook_Open event ?? | Excel Programming |