Help with a very complicated For each Next code
I am guessing this should work:
Dim i As Integer
Dim j As Integer
For i = 1 To 55 Step 2
For j = i + 2 To 55 Step 2
If Me.Controls("DTPicker" & i).Value _
Me.Controls("DTPicker" & j).Value Then
if Me.Controls("txtbx" & i + 1).value="Projected"
and _
Me.Controls("txtbx" & j +
1).value="Projected" then
Me.Controls("txtbx" & i +1).BackColor=&HFFFFFF
Me.Controls("txtbx" & i + 1).ForeColor = &H0&
end if
End If
Next j
Next i
"Jacob Skaria" wrote:
Try the below..
Dim i As Integer
For i = 1 To 55 Step 2
If Me.Controls("DTPicker" & i).Value _
Me.Controls("DTPicker" & i + 2).Value Then
Me.Controls("txtbx" & i + 1).BackColor = &HFFFFFF
Me.Controls("txtbx" & i + 1).ForeColor = &H0&
End If
Next
If this post helps click Yes
---------------
Jacob Skaria
"Ayo" wrote:
I have a form with 26 DTPickers and 26 TextBoxes, with each DTPicker
associated to a TextBox by the name i.e. DTPicker1 is next to txtbx2,
DTPicker3 is next to txtbx4, DTPicker5 is next to txtbx6, ..., DTPicker55 is
next to txtbx56.
Now I am trying to write a code that does the following:
1.) For each DTPicker on the form, I want to check its value against every
DTPicker after it, for example if:
DTPicker1.value DTPicker3.value
then I want to change the Backcolor of txtbx2 to White. In other words, if:
For each DTPicker in UserForm2
For i=1 to 55 step 2
DTPicker(i).value DTPicker(i+2).value then:
txtbx(i+1).BackColor = &HFFFFFF
txtbx(i+1).ForeColor = &H0&
This is what I am trying to do in a nut shell but I can't figure out exactly
how to code it. Any help will be greatly appreciated.
Thanks
Ayo
|