Solved

Run-time error 91

Posted on 2014-09-08
7
157 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 45

Expert Comment

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

Sheets("Menu").Activate
0
 
LVL 45

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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 45

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 45

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction While answering a recent question (http:/Q_27311462.html), I created an alternative function to the Excel Concatenate() function that you might find useful.  I tested several solutions and share the results in this article as well as t…
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.

705 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now