Hi all,
I am trying to create a list in an excel macro. What i mean by this is that basically i am listing a group of cells that i want the macro to look in. the list will be like this but much bigger (A2,A3,A4,B6,B7,B23,C34,C5,C6....) instead of creating hundreds of different for loops, looping through each sheet to find something in that specific cell, i would have to create a for loop for Cell A2, Cell A3..... instead i would like excel to just look at my list and loop through the sheets for that cell then move onto the next cell that i have on the list and loop through all the sheets for that cell.
I would think i would be setting a variable to be as a list, then listing out all of the cells for it. something like this, but i am not sure
Sub Summary()
Dim CellList as ...... 'this would be something like range, or list or dictionary
CellList = "A3,A4,A5,B6,B3,B7,C3,C7,F4,F3..." 'this would be the full list maybe 100 cells
Count = 0 'this is a running count for the criteria below
counter = 1 'This would be the number in the list. it will count so that the loop will go through the list
SheetCount = 2 'tells you what sheet your on
While counter < 23 'or however many references are in CellList
While SheetCount < 5
Sheets(SheetCount).Select
If CellList.counter.Interior.Color <> 12777619 Then 'this is saying that, if it is the first loop, A3 is not a certain color then...
Count = Count + 1
End If
SheetCount = SheetCount + 1
Wend
counter = counter + 1
Wend
End Sub
This is sort of what i am doing
Thanks in advance for any help. and please let me know if i can help explaining it better, it may be a little confusing.
I may need to do this as a function instead, but i am not very familiar with that
Bookmarks