Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Reference Controls to chang attributes through Array

I have 3 CommandButton controls (cmd_1, cmd_2, ... cmd_10)

I want to be able to cycle through them to change their attributes using
data stored in an array cb(10). I know I'm missing something simple, but
integral. Can anyone help?

I've tried:

Dim myObj as Object
Dim x as Interger

For x = 1 to 10

Set myObj = "cmd_" & x
With myObj
.Visible = cb(x)
End With

Next x
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Reference Controls to chang attributes through Array

On a worksheet?

dim x as long 'watch your spelling of integer
with activesheet
for x = 1 to 10
.oleobjects("cmd_" & x).visible = cb(x)
next x
end with

cb() is an array of true/falses, right.

Ps. I'd use:
dim CB(1 to 10) as boolean

dim CB(10) as boolean
will create an array of 11 elements--0 to 10.
(unless you're using an "Option Base" statement.)

DanB wrote:

I have 3 CommandButton controls (cmd_1, cmd_2, ... cmd_10)

I want to be able to cycle through them to change their attributes using
data stored in an array cb(10). I know I'm missing something simple, but
integral. Can anyone help?

I've tried:

Dim myObj as Object
Dim x as Interger

For x = 1 to 10

Set myObj = "cmd_" & x
With myObj
.Visible = cb(x)
End With

Next x


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Reference Controls to chang attributes through Array

Sorry Dave,

I meant on a UserForm.

I already have cb() as Boolean in Public declarations.

Any thoughts?

Dan

"Dave Peterson" wrote:

On a worksheet?

dim x as long 'watch your spelling of integer
with activesheet
for x = 1 to 10
.oleobjects("cmd_" & x).visible = cb(x)
next x
end with

cb() is an array of true/falses, right.

Ps. I'd use:
dim CB(1 to 10) as boolean

dim CB(10) as boolean
will create an array of 11 elements--0 to 10.
(unless you're using an "Option Base" statement.)

DanB wrote:

I have 3 CommandButton controls (cmd_1, cmd_2, ... cmd_10)

I want to be able to cycle through them to change their attributes using
data stored in an array cb(10). I know I'm missing something simple, but
integral. Can anyone help?

I've tried:

Dim myObj as Object
Dim x as Interger

For x = 1 to 10

Set myObj = "cmd_" & x
With myObj
.Visible = cb(x)
End With

Next x


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Reference Controls to chang attributes through Array

Dim x As Long 'watch your spelling of integer
For x = lbound(cb) to ubound(cb) 'better than hardcoding the numbers
Me.Controls("cmd_" & x).Visible = cb(x)
Next x


And when I used lbound() and ubound(), you'll have to use: dim cb(1 to 10), not
just cb(10).




DanB wrote:

Sorry Dave,

I meant on a UserForm.

I already have cb() as Boolean in Public declarations.

Any thoughts?

Dan

"Dave Peterson" wrote:

On a worksheet?

dim x as long 'watch your spelling of integer
with activesheet
for x = 1 to 10
.oleobjects("cmd_" & x).visible = cb(x)
next x
end with

cb() is an array of true/falses, right.

Ps. I'd use:
dim CB(1 to 10) as boolean

dim CB(10) as boolean
will create an array of 11 elements--0 to 10.
(unless you're using an "Option Base" statement.)

DanB wrote:

I have 3 CommandButton controls (cmd_1, cmd_2, ... cmd_10)

I want to be able to cycle through them to change their attributes using
data stored in an array cb(10). I know I'm missing something simple, but
integral. Can anyone help?

I've tried:

Dim myObj as Object
Dim x as Interger

For x = 1 to 10

Set myObj = "cmd_" & x
With myObj
.Visible = cb(x)
End With

Next x


--

Dave Peterson


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Reference Controls to chang attributes through Array

Dave,

Thanks so much. I believe that this does it.

Much appreciated,

Dan

"Dave Peterson" wrote:

Dim x As Long 'watch your spelling of integer
For x = lbound(cb) to ubound(cb) 'better than hardcoding the numbers
Me.Controls("cmd_" & x).Visible = cb(x)
Next x


And when I used lbound() and ubound(), you'll have to use: dim cb(1 to 10), not
just cb(10).




DanB wrote:

Sorry Dave,

I meant on a UserForm.

I already have cb() as Boolean in Public declarations.

Any thoughts?

Dan

"Dave Peterson" wrote:

On a worksheet?

dim x as long 'watch your spelling of integer
with activesheet
for x = 1 to 10
.oleobjects("cmd_" & x).visible = cb(x)
next x
end with

cb() is an array of true/falses, right.

Ps. I'd use:
dim CB(1 to 10) as boolean

dim CB(10) as boolean
will create an array of 11 elements--0 to 10.
(unless you're using an "Option Base" statement.)

DanB wrote:

I have 3 CommandButton controls (cmd_1, cmd_2, ... cmd_10)

I want to be able to cycle through them to change their attributes using
data stored in an array cb(10). I know I'm missing something simple, but
integral. Can anyone help?

I've tried:

Dim myObj as Object
Dim x as Interger

For x = 1 to 10

Set myObj = "cmd_" & x
With myObj
.Visible = cb(x)
End With

Next x

--

Dave Peterson


--

Dave Peterson

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Controls Array RyanH Excel Programming 2 November 13th 07 06:50 PM
Data value display attributes linked to table attributes MDT at Paragon Home Inspections, LLC Charts and Charting in Excel 0 November 15th 06 12:53 AM
array of userform controls Doug Glancy Excel Programming 3 June 5th 05 10:37 AM
excel VBA set array controls Jason[_31_] Excel Programming 1 June 30th 04 11:38 PM
Setting attributes for controls Don Madsen Excel Programming 2 October 29th 03 01:27 AM


All times are GMT +1. The time now is 06:22 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"