bug in excel VBA?

Posted on 1998-10-14
Last Modified: 2010-04-30

  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!

Question by:sunjian061197
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

Expert Comment

ID: 1440023
Try DoEvents, to do forgotten events.


Author Comment

ID: 1440024
Hi fguerreiro_inix:

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

Sub command1_click()
end sub

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


Expert Comment

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.

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

LVL 13

Accepted Solution

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


Author Comment

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


Author Comment

ID: 1440028

  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....


Featured Post

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!

Question has a verified solution.

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

Suggested Solutions

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
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.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

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