Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
hi the following code that goes through a range and see if
the cell 7 cells from the active cell is 4 and if it is it shade the cells in the row green what i wanted to know can i put all the rng offsets in an array instead of doing it how i have this is what i have Sub fill_it() Dim rng As Range For Each rng In Range("test") If rng.Offset(0, 7).Value = 4 Then rng.Select Selection.Interior.ColorIndex = 4 rng.Offset(0, 1).Select Selection.Interior.ColorIndex = 4 rng.Offset(0, 2).Select Selection.Interior.ColorIndex = 4 rng.Offset(0, 3).Select Selection.Interior.ColorIndex = 4 rng.Offset(0, 4).Select Selection.Interior.ColorIndex = 4 rng.Offset(0, 5).Select Selection.Interior.ColorIndex = 4 rng.Offset(0, 6).Select Selection.Interior.ColorIndex = 4 rng.Offset(0, 7).Select Selection.Interior.ColorIndex = 4 rng.Offset(0, 8).Select Selection.Interior.ColorIndex = 4 end if next rng end sub thanks aneurin |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Not an array, but how about:
Sub fill_it() Dim rng As Range For Each rng In Range("test") If rng.Offset(0, 7).Value = 4 Then rng.Resize(1, 9).Interior.ColorIndex = 4 End If Next rng End Sub -- Dianne In , Aneurin typed: hi the following code that goes through a range and see if the cell 7 cells from the active cell is 4 and if it is it shade the cells in the row green what i wanted to know can i put all the rng offsets in an array instead of doing it how i have this is what i have Sub fill_it() Dim rng As Range For Each rng In Range("test") If rng.Offset(0, 7).Value = 4 Then rng.Select Selection.Interior.ColorIndex = 4 rng.Offset(0, 1).Select Selection.Interior.ColorIndex = 4 rng.Offset(0, 2).Select Selection.Interior.ColorIndex = 4 rng.Offset(0, 3).Select Selection.Interior.ColorIndex = 4 rng.Offset(0, 4).Select Selection.Interior.ColorIndex = 4 rng.Offset(0, 5).Select Selection.Interior.ColorIndex = 4 rng.Offset(0, 6).Select Selection.Interior.ColorIndex = 4 rng.Offset(0, 7).Select Selection.Interior.ColorIndex = 4 rng.Offset(0, 8).Select Selection.Interior.ColorIndex = 4 end if next rng end sub thanks aneurin |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Complex conditional summing - array COUNT works, array SUM gives#VALUE | Excel Worksheet Functions | |||
Array formula: how to join 2 ranges together to form one array? | Excel Worksheet Functions | |||
Prevent cell/array references from changing when altering/moving thecell/array | Excel Discussion (Misc queries) | |||
meaning of : IF(Switch; Average(array A, array B); array A) | Excel Worksheet Functions | |||
combining cells and array from different sheets into an array to pass to IRR() | Excel Discussion (Misc queries) |