?
Solved

Run-time error 91

Posted on 2014-09-08
7
Medium Priority
?
176 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 49

Expert Comment

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

Sheets("Menu").Activate
0
 
LVL 49

Assisted Solution

by:Martin Liss
Martin Liss earned 2000 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
Technology Partners: 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 49

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 49

Accepted Solution

by:
Martin Liss earned 2000 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

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,…
Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

752 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