Solved

Run-time error 91

Posted on 2014-09-08
7
170 Views
Last Modified: 2014-09-08
Folks,
When my workbook is launched it opens with the following error:
DashboardI added in the Name Manager a range at AA from the Topics worksheet and it is labeled TextFormulaFunction. No problem here.
My workbook requires I add the worksheet name to the worksheet "SheetNames" - no problem here.
My workbook requires the name of a Category in the Topics worksheet at AE - no problem here.
Code was need on the Menu tab in the Worksheet_SelectionChange event. No problem here
However, when I select the new Category, in the case Text Formulas and Function I get this:
Objectat this part of the code
run time errorMy ranges from A:Z work fine. It's when I go beyond Z that this problem comes up
Dashboard-rev.xlsm
0
Comment
Question by:Frank Freese
  • 4
  • 3
7 Comments
 
LVL 47

Expert Comment

by:Martin Liss
ID: 40310677
Just before the last line in Workbook_Open add

Sheets("Menu").Activate
0
 
LVL 47

Assisted Solution

by:Martin Liss
Martin Liss earned 500 total points
ID: 40310689
You should also add Application.ScreenUpdaing lines so that the sub looks like this
Private Sub Workbook_Open()

    Application.ScreenUpdating = False
    
    GenCategoryFormulas Sheets("Topics").Range("Category").Rows.Count
    
    Sheets("ScrollbarData").Range("C3").Value = Range("Category").Rows.Count

    ' Select the first category
    Range("A3").Select

    ActiveWindow.Zoom = 90
    '  Make sure that the statusbar is visible
    Application.DisplayStatusBar = True
    
    Application.StatusBar = "Concept and design by Frank Freese. Programming by MartinLiss at www.experts-exchange.com."
    
    Sheets("Menu").Activate
    ActiveSheet.ScrollBars("vscrTopic").Value = 1
    
    Application.ScreenUpdating = True
    
End Sub

Open in new window

0
 

Author Comment

by:Frank Freese
ID: 40310727
Before I actually change the code in the Workbook_Open event I want to be positive this is what you're asking:
Private Sub Workbook_Open()

    Application.ScreenUpdating = False
    
    GenCategoryFormulas Sheets("Topics").Range("Category").Rows.Count
    
    Sheets("ScrollbarData").Range("C3").Value = Range("Category").Rows.Count

    ' Select the first category
    Range("A3").Select

    ActiveWindow.Zoom = 90
    '  Make sure that the statusbar is visible
    Application.DisplayStatusBar = True
    
    Application.StatusBar = "Concept and design by Frank Freese. Programming by MartinLiss at www.experts-exchange.com."
    
    Sheets("Menu").Activate
    ActiveSheet.ScrollBars("vscrTopic").Value = 1
    Sheets("Menu").Activate
    Application.ScreenUpdating = True
    
End Sub

Open in new window

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 47

Expert Comment

by:Martin Liss
ID: 40310747
You don't need line 20 in your code. Even after you make that change you'll run into another problem which I'm working on now.
0
 
LVL 47

Accepted Solution

by:
Martin Liss earned 500 total points
ID: 40310779
The problems occurred when you actually clicked Text Formulas and Functions
The first problem was mine and was due to the gstrTopicCol calculation in Menu's Worksheet_SelectionChange event. It worked fine when the Topics column was a single letter, but the new AA column caused a problem. Here's the fix.

In that sub, change
gstrTopicCol = Mid$(Range("D3").Formula, InStr(1, Range("D3").Formula, "!") + 1, 1)

Open in new window

to
    Dim intStartPos As Integer
    Dim intEndPos As Integer
    intStartPos = InStr(1, Range("D3").Formula, "!") + 1
    intEndPos = InStr(intStartPos, Range("D3").Formula, ",") - 1
    gstrTopicCol = Mid$(Range("D3").Formula, intStartPos, intEndPos - intStartPos)

Open in new window


To be consistent the two new Dim statements should be moved to the top of the sub with the rest of them.

The other problem is yours.
In Name Manager you had TextFormulaFunction as the name of your new range while in code you referred in at least one of the two places that name is referred to you had TextFormulaFunctions. I changed the Named Range name to TextFormulaFunctions and made sure that both places in the code matched.
0
 

Author Comment

by:Frank Freese
ID: 40310848
OK...look like we're back on track. Changes from this thread have been implemented. Looks good.
Thanks again.
0
 

Author Closing Comment

by:Frank Freese
ID: 40310856
again, many thanks
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question