Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Returning to INdexing labels and coloring them by group

Posted on 2004-10-26
7
Medium Priority
?
134 Views
Last Modified: 2010-05-02
A couple of days ago I asked about how to give all labels on a form the same background color. I received 2 excellent replies; unfortunately, one of them does not work for excel.

It is this one

Pub sub command1_click()
Dim i as integer
for i = 0 to Userform3.label1.ubound
userform3.label1.item(i).backcolor=rgb(240,100,0)
next i
end sub

The problem seems to be that it will not let me see or create an indexed label with the same name.

I've tired
dim a as label 'works

but I cannot put anything on the form with the same name and if there is a way to create and use an array of labels I surely don't know how to do it.

Please help

Jerome
Vinnyd79 if you are around, this was originally your code.
0
Comment
Question by:jcherry_99
[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
7 Comments
 
LVL 28

Expert Comment

by:vinnyd79
ID: 12416867
You have to set the index property on the first label to 0.
0
 
LVL 32

Expert Comment

by:Erick37
ID: 12416950
VBA does not support control arrays. In VBA you can use this:

Dim c As Control

For Each c In Controls

    If TypeOf c Is msforms.Label Then
        c.BackColor = &HCC8080
    End If
   
Next
0
 

Author Comment

by:jcherry_99
ID: 12417319
To Vinny

The problem is that I cannot set the index to zero. I don't think excell does that. Nor do I know how to get excel to copy labels on a form so that they all have the same name.

Perhaps VB can do that, but I don't think excel can

Take good care

Jerome
0
 
LVL 32

Expert Comment

by:Erick37
ID: 12871072
I can verify it works
:)
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 12898570
PAQed with no points refunded (of 50)

modulo
Community Support Moderator
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

636 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