Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello all,
I am trying to solve this situation by click event and NOT by selectionchange event.. So, no target.value stuff. All I am trying to do is pretty simple (but I face errors..). It is as follows. I have given examples with the algorithm to ease reader's understanding (hopefully) In the range("A2:A6"), check the following for each cell. 1. If any cell has a colorindex = 3,4,or 6 then 2. Consider that cell's row. For example, if A3 is a cell that has a colorindex of 3,4 or 6 then consider B3 to IV3 3. In that row, if any cell has a numerical value, then highlight the first cell of the corresponding column. For example, in B3 to IV3, if E3, G3, J3 have a numerical value, then highlight E1, G1, J1 with a colorindex 3. 4. Do the same for every cell in that range("A2:A6"). I have written the following code for this.. I face an error that says that 'for' control is already in use. But, I cant think about modifying the code without two 'for' statements. Please provide your expertise to solve this problem. Private Sub CommandButton1_Click() For Each cell In Sheet1.Range("A2:A6") If cell.Interior.ColorIndex = 3 Or cell.Interior.ColorIndex = 6 Or cell.Interior.ColorIndex = 4 Then Range("B1:IV1").Interior.ColorIndex = xlNone Set rng = cell.Offset(0, 1).Resize(1, 255) Set rng1 = Nothing On Error Resume Next Set rng1 = rng.SpecialCells(xlConstants) On Error GoTo 0 If Not rng1 Is Nothing Then For Each cell In rng1 If cell.Value < 0 Or cell.Value 0 Then Sheet1.Cells(1, cell.Column).Interior.ColorIndex = 3 End If Next End If End If Next End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Rectify function - combination of Sumproduct and OR | Excel Worksheet Functions | |||
How rectify the DATA Error [47 OF 94 33 F4 55] | Excel Discussion (Misc queries) | |||
Protect Sheet with code, but then code will not Paste error. How do i get around this. Please read for explainations.... | Excel Programming | |||
i cannot use the mouse right click in excel. how to rectify? | New Users to Excel | |||
query wizard has stopped working how do i rectify this | Excel Worksheet Functions |