Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
hi!
I have this code and I want to have it inside a loop. Am I supposed to somhow empty MyRange and MyRange1 for every loop?? Sheets("Blad3").Select Columns(1).Select Dim MyRange As Range, MyRange1 As Range Set MyRange = ActiveSheet.UsedRange For Each c In MyRange If c.Interior.ColorIndex = 40 Then If c.Interior.Pattern = xlSolid Then If MyRange1 Is Nothing Then Set MyRange1 = c Else Set MyRange1 = Union(MyRange1, c) End If End If End If Next average_färg = WorksheetFunction.Average(MyRange1) maxvalue_färg = WorksheetFunction.max(MyRange1) medianvalue_färg = WorksheetFunction.Median(MyRange1) |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
What is it you want to loop through? It currently loops through every cell in the active sheet used range and checks the colour. What do you want it to do? Columns(1).Select The above line is erroneous, it adds nothing to what is going on. Mike "Ksenija" wrote: hi! I have this code and I want to have it inside a loop. Am I supposed to somhow empty MyRange and MyRange1 for every loop?? Sheets("Blad3").Select Columns(1).Select Dim MyRange As Range, MyRange1 As Range Set MyRange = ActiveSheet.UsedRange For Each c In MyRange If c.Interior.ColorIndex = 40 Then If c.Interior.Pattern = xlSolid Then If MyRange1 Is Nothing Then Set MyRange1 = c Else Set MyRange1 = Union(MyRange1, c) End If End If End If Next average_färg = WorksheetFunction.Average(MyRange1) maxvalue_färg = WorksheetFunction.max(MyRange1) medianvalue_färg = WorksheetFunction.Median(MyRange1) |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Looping rather than code for each row | Excel Programming | |||
Code looping through files | Excel Programming | |||
Help with Looping Code | Excel Programming | |||
Looping macros using VB code | Excel Discussion (Misc queries) | |||
Code looping when it should not | Excel Programming |