Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Cycling through form fields

Help
I can use FOR statements with a range in a spreadsheet...

i.e: For Rownumber = 5 To EndOfList
'Gets the name and whether outstanding or not from the
spreadsheet
VName = Range("A" & Rownumber).Value
VOut = Range("J" & Rownumber).Value

But I want to know how to cycle through a set of comboboxes using a
WITH statement.

i.e: For x = 1 To 15

vBoxName = (cboxDay & x)

With vBoxName
.additem ("1")
.additem ("2")
...
End With
Next

I can't seem to get the syntax correct to fill the field cboxDay1,
then fill the box cboxDay2 ..... with the same info.

I don't want to have to right the same code out for all 45 boxes.

Any solution would be appreciated.
cheers
Aaron
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Cycling through form fields

How about this

Dim ctl As msforms.Control

For Each ctl In Me.Controls
If TypeName(ctl) = "ComboBox" Then
With ctl
.AddItem ("1")
.AddItem ("2")
' ...
End With
End If
Next ctl

--

HTH

RP

"Azza" wrote in message
m...
Help
I can use FOR statements with a range in a spreadsheet...

i.e: For Rownumber = 5 To EndOfList
'Gets the name and whether outstanding or not from the
spreadsheet
VName = Range("A" & Rownumber).Value
VOut = Range("J" & Rownumber).Value

But I want to know how to cycle through a set of comboboxes using a
WITH statement.

i.e: For x = 1 To 15

vBoxName = (cboxDay & x)

With vBoxName
.additem ("1")
.additem ("2")
...
End With
Next

I can't seem to get the syntax correct to fill the field cboxDay1,
then fill the box cboxDay2 ..... with the same info.

I don't want to have to right the same code out for all 45 boxes.

Any solution would be appreciated.
cheers
Aaron



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
Set up form fields to that Tab can be used to move from one to ano Mica Excel Discussion (Misc queries) 0 February 10th 10 10:11 PM
Form Fields Anna Excel Discussion (Misc queries) 1 November 21st 06 12:42 AM
Form Fields mcaalcorn Excel Discussion (Misc queries) 0 March 3rd 06 11:06 AM
Pivot Table Cycling Through Page Fields Automatically nrehman Excel Discussion (Misc queries) 14 October 13th 05 07:32 PM


All times are GMT +1. The time now is 09:45 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"