Solved

bug in excel VBA?

Posted on 1998-10-14
6
193 Views
Last Modified: 2010-04-30
Hi,

  I encountered something very strange in Excel VBA. I have created a number of labels and want to control their visibility under a certain cases. For example, whenever I click on a button, the labels will toggle their visibility. I found that when the number of labels is less than 13, it works fine. Otherwise, some labels still show up even I set their visibility to be False..  Did anybody encounter this before? Is this a known bug? Any comment is appreciated!

sunjian
0
Comment
Question by:sunjian061197
6 Comments
 
LVL 3

Expert Comment

by:fguerreiro_inix
ID: 1440023
Try DoEvents, to do forgotten events.

Regards
0
 

Author Comment

by:sunjian061197
ID: 1440024
Hi fguerreiro_inix:

  Would you pls elaberate more? You see my code might just look like following:

Sub command1_click()
label1.visible=false
label2.visible=false
.
label12.visible=false
label13.visible=false
end sub

However, after i click the command button, label13 is still visible...

sunjian
0
 
LVL 2

Expert Comment

by:shchuka
ID: 1440025
What version of excel are you using?  I just tried what you said in Excel 97 - and all 13 labels got hidden.  I think there's something with your code.  Make sure you reference the names correctly.  Maybe, your 13th label has name different than 'label13' and you have 'on error resume next' or something like this so that it doesn't give you an error.

-Aleks.
0
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
LVL 13

Accepted Solution

by:
Mirkwood earned 50 total points
ID: 1440026
No problem in Excel 97.

I tried the code below
   Label1.Visible = Not Label1.Visible
    Label2.Visible = Not Label2.Visible
    Label3.Visible = Not Label3.Visible
    Label4.Visible = Not Label4.Visible
    Label5.Visible = Not Label5.Visible
    Label6.Visible = Not Label6.Visible
    Label7.Visible = Not Label7.Visible
    Label8.Visible = Not Label8.Visible
    Label9.Visible = Not Label9.Visible
    Label10.Visible = Not Label10.Visible
    Label11.Visible = Not Label11.Visible
    Label12.Visible = Not Label12.Visible
    Label13.Visible = Not Label13.Visible
    Label14.Visible = Not Label14.Visible
    Label15.Visible = Not Label15.Visible
    Label16.Visible = Not Label21.Visible
    Label17.Visible = Not Label21.Visible
    Label18.Visible = Not Label21.Visible
    Label19.Visible = Not Label21.Visible
    Label20.Visible = Not Label21.Visible
    Label21.Visible = Not Label21.Visible
    Label22.Visible = Not Label22.Visible
    Label23.Visible = Not Label23.Visible
    Label24.Visible = Not Label24.Visible
    Label25.Visible = Not Label25.Visible
    Label26.Visible = Not Label26.Visible
    Label27.Visible = Not Label27.Visible
    Label28.Visible = Not Label28.Visible
    Label29.Visible = Not Label29.Visible
    Label30.Visible = Not Label30.Visible



0
 

Author Comment

by:sunjian061197
ID: 1440027
ooops!!! My excel version is also Excel 97... Let me check and try again...

sunjian
0
 

Author Comment

by:sunjian061197
ID: 1440028
Hi!

  I still got problem when I do it in that computer... But after I changed to another PC, it's all fine. I checked out my typings very carefully and there shouldn't be any error....

sunjian
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

813 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

14 Experts available now in Live!

Get 1:1 Help Now