Solved

Using Booleans globally in excel vba

Posted on 2007-03-27
2
239 Views
Last Modified: 2010-04-30
I am trying to set up a boolean 'HideRows' globally. Within the 'Summary' tab, CodeB hides all of the empty rows when that worksheet is activated. I don't want that code activated until after 'CodeA' is run. So what I did below is set up HideRows = False and then after CodeA is run, I set HideRows = True.
Then, in the Worksheet's code, I have an if statement saying that if HideRows = True then execute CodeB

Public HideRows As Boolean
HideRows = False
Sub CodeA
HideRows = True

'Summary Worksheet Code
Private Sub Worksheet_Activate()
If HideRows = True Then
        Execute CodeB
End if
End Sub

What am I doing wrong?
0
Comment
Question by:tiehaze
2 Comments
 

Author Comment

by:tiehaze
ID: 18804083
For clarification, the problem that I am having is in:

'Summary Worksheet Code
Private Sub Worksheet_Activate()
If HideRows = True Then
        Execute CodeB
End if
End Sub

It isn't executing CodeB and therefor must not be recognizing HideRows as true
0
 
LVL 81

Accepted Solution

by:
zorvek (Kevin Jones) earned 500 total points
ID: 18804167
Place this code in your worksheet module:

Public HideRows As Boolean

Private Sub Worksheet_Activate()
   If HideRows Then CodeB
End Sub

The other code should look like:

   CodeA
   Sheets("Summary").HideRows = True

Kevin
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…

707 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

15 Experts available now in Live!

Get 1:1 Help Now