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

I have this code:

'Checks if the complee date fied has been completed
Dim vDateComplete1 As Long
vDateComplete1 = 0
If cboxDay1 < "" Then
vDateComplete1 = vDateComplete1 + 1
End If
If cboxMonth1 < "" Then
vDateComplete1 = vDateComplete1 + 1
End If
If cboxYear1 < "" Then
vDateComplete1 = vDateComplete1 + 1
End If
If vDateComplete1 < (0 Or 3) Then
MsgBox "Please complete the date field"
cboxDay1.SetFocus
End If

and three combo boxes for day, month and year.

The problem is I have 15 of these date fields to check and although I
know how to cycle though a spreadsheet (For Rownumber = 1 to ....), I
do not know how
to cycle through fields in a form.
i.e. I have cboxDay1, cboxDay2 .... and I do not know how to
varibalise it ??

I was given the code With Me.Controls("ComboBox" & i) to fill the
boxes but unsure what the "Controls" part of the code does and if to
use it for the next part of the code.

Please help - my spreadsheet is looking so jammy with loads and loads
of uneccessary code.

cheers
Aaron
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Cycling through variables.

This might help get you started

'-----------------------------------------------------------------
Private Sub SetComboboxes()
'-----------------------------------------------------------------
Dim ctl As msforms.Control

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

End Sub


--

HTH

RP

"Azza" wrote in message
m...
I have this code:

'Checks if the complee date fied has been completed
Dim vDateComplete1 As Long
vDateComplete1 = 0
If cboxDay1 < "" Then
vDateComplete1 = vDateComplete1 + 1
End If
If cboxMonth1 < "" Then
vDateComplete1 = vDateComplete1 + 1
End If
If cboxYear1 < "" Then
vDateComplete1 = vDateComplete1 + 1
End If
If vDateComplete1 < (0 Or 3) Then
MsgBox "Please complete the date field"
cboxDay1.SetFocus
End If

and three combo boxes for day, month and year.

The problem is I have 15 of these date fields to check and although I
know how to cycle though a spreadsheet (For Rownumber = 1 to ....), I
do not know how
to cycle through fields in a form.
i.e. I have cboxDay1, cboxDay2 .... and I do not know how to
varibalise it ??

I was given the code With Me.Controls("ComboBox" & i) to fill the
boxes but unsure what the "Controls" part of the code does and if to
use it for the next part of the code.

Please help - my spreadsheet is looking so jammy with loads and loads
of uneccessary code.

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
Tab keeps cycling through the same row Mike Excel Discussion (Misc queries) 2 August 14th 08 12:20 AM
Cycling through workbooks Nico Excel Discussion (Misc queries) 4 July 4th 08 10:09 PM
Cycling through predefined worksheets Craig M Excel Programming 3 July 1st 04 07:58 AM
Cycling though all sheets in the workbook James[_14_] Excel Programming 5 February 27th 04 04:11 PM
Cycling through worksheets Chris Gorham[_3_] Excel Programming 2 November 5th 03 08:37 PM


All times are GMT +1. The time now is 12:20 PM.

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"