Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Yes, rows should be formatted blue only if all the related conditions for all
selected checkboxes are true. And if any related condition is false, then no row should be formatted blue. You are correct, its all or nothing, Here a description of what I am trying to do: I have table of data where the first row represents the stock data of the day and other calculated values. Each subsequent row represents another day with its calculated values. So this table then has many rows and 16 columns of data. I will then, using checkboxes choose a combination of several different conditions for testing. The program will loop through the first row and tests wether the combination of all the different conditions on this particular day are true. If so, this row will be colored blue. A typical condition would be: is todays volume higher than yesterdays? ie. (if cells(10 + i,6)cells(9 + i,6) Then).And there would be several more of this kind It will then move to the next row and repeat the test with those same conditions until it reaches the end of the table. I will then have a table where some rows are colored blue because they satisfied all selected conditions. The purpose of this is to use the most promising combinations of conditions for forecasting bullish or bearish stock trends. It is a quick way to check out your stock system. I accidentally copied the wrong €śCase€ť lines previously, the code below is the correct one. I apologize for this and for any other confusion I caused earlier. Do you think this project can be done ? Private Sub CommandButton1_Click() Dim ctl As Control Dim bolCheck As Boolean Dim i As Integer Dim wks As Worksheet Set wks = Worksheets("day1") bolCheck = True For i = 1 To 23 Set ctl = UserForm1.Controls("Checkbox" & i) If ctl = True Then 'This checkbox is selected. Is its related condition True? Select Case i Case 1 If Not wks.Cells(10 + i, 3).Value wks.Cells(9 + i, 3).Value Then bolCheck = False 'spread Case 2 If Not wks.Cells(10 + i, 3).Value < wks.Cells(9 + i, 3).Value Then bolCheck = False 'vol Case 3 If Not wks.Cells(10 + i, 4).Value wks.Cells(9 + i, 4).Value Then bolCheck = False Case 4 If Not wks.Cells(10 + i, 4).Value < wks.Cells(9 + i, 4).Value Then bolCheck = False Case 5 If Not wks.Cells(10 + i, 5).Value wks.Cells(9 + i, 5).Value Then bolCheck = False Case 6 If Not wks.Cells(10 + i, 5).Value < wks.Cells(9 + i, 5).Value Then bolCheck = False Case 7 If Not wks.Cells(10 + i, 6).Value wks.Cells(9 + i, 6).Value Then bolCheck = False Case 8 If Not wks.Cells(10 + i, 6).Value < wks.Cells(9 + i, 6).Value Then bolCheck = False Case 9 If Not wks.Cells(10 + i, 7).Value wks.Cells(9 + i, 7).Value Then bolCheck = False Case 10 If Not wks.Cells(10 + i, 7).Value < wks.Cells(9 + i, 7).Value Then bolCheck = False Case 11 If Not wks.Cells(10 + i, 8).Value wks.Cells(9 + i, 8).Value Then bolCheck = False Case 12 If Not wks.Cells(10 + i, 8).Value < wks.Cells(9 + i, 8).Value Then bolCheck = False Case 13 If Not wks.Cells(10 + i, 9).Value wks.Cells(9 + i, 9).Value Then bolCheck = False Case 14 If Not wks.Cells(10 + i, 9).Value < wks.Cells(9 + i, 9).Value Then bolCheck = False Case 15 If Not wks.Cells(10 + i, 10).Value wks.Cells(9 + i, 10). Value Then bolCheck = False Case 16 If Not wks.Cells(10 + i, 10).Value < wks.Cells(9 + i, 10). Value Then bolCheck = False Case 17 If Not wks.Cells(10 + i, 11).Value wks.Cells(9 + i, 11). Value Then bolCheck = False Case 18 If Not wks.Cells(10 + i, 11).Value < wks.Cells(9 + i, 11). Value Then bolCheck = False Case 19 If Not wks.Cells(10 + i, 12).Value wks.Cells(9 + i, 12). Value Then bolCheck = False Case 20 If Not wks.Cells(10 + i, 12).Value < wks.Cells(9 + i, 12). Value Then bolCheck = False Case 21 If Not wks.Cells(10 + i, 13).Value wks.Cells(9 + i, 13). Value Then bolCheck = False Case 22 If Not wks.Cells(10 + i, 13).Value < wks.Cells(9 + i, 13). Value Then bolCheck = False Case 23 If Not wks.Cells(10 + i, 14).Value wks.Cells(9 + i, 14). Value Then bolCheck = False End Select End If If bolCheck = False Then '(Optional) 'A related condition is False. No need to continue checking any more 'boxes or conditions. Exit For End If Next i If bolCheck = True Then 'Do whatever it is you want to do if all conditions related to the 'checked boxes are True 'Call BlueRow blue End If End Sub Sub BlueRow() ' color rows blue Dim i As Integer Dim wks As Worksheet Set wks = Worksheets("day1") For i = 1 To 23 If UserForm1.Controls("Checkbox" & i) = True Then wks.Range(Cells(10 + i, 2), wks.Cells(10 + i, 16)).Interior. ColorIndex = 5 End If Next i End Sub -- Message posted via OfficeKB.com http://www.officekb.com/Uwe/Forums.a...mming/200802/1 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Multiple Insert Copied Cells routine | Excel Discussion (Misc queries) | |||
Setting multiple conditions to return a figure from multiple cells | Excel Discussion (Misc queries) | |||
SUMPRODUCT or INDEX/MATCH for multiple conditions and multiple rec | Excel Discussion (Misc queries) | |||
Combining Text from multiple cells under multiple conditions | Excel Worksheet Functions | |||
How to multiple conditions to validate more than 2 conditions to . | Excel Worksheet Functions |