Results 1 to 3 of 3

Create a list in excel macro

Threaded View

  1. #1
    Forum Contributor
    Join Date
    08-22-2011
    Location
    Texas, United States
    MS-Off Ver
    Excel 2007 and 2010
    Posts
    516

    Create a list in excel macro

    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
    Last edited by amotto11; 11-20-2012 at 06:15 PM.
    Regards,
    amotto

    If I helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1