+ Reply to Thread
Results 1 to 4 of 4

script to write 1's and zero's for cell color

Hybrid View

  1. #1
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: script to write 1's and zero's for cell color

    Seeing as you are using Excel 2007 and it allows filtering by color, you can script this.
    Here is an example you can build on:

    Note: you will need to determine the RGB value of the cell color, which can be done by simply activating the cell and calling up the color pallet via Format Cells. If you have multiple cell colors then you will need multiple passes to accomplish.

    Using the specialcells method will be much faster than looping through 600K cells.

    Option Explicit
    
    Sub Check_Cell_Color()
    
        Application.ScreenUpdating = False
        
        With Sheet1
            If .AutoFilterMode = True Then .AutoFilterMode = False
            .Range("B1:B600000").AutoFilter Field:=1, Criteria1:=RGB(242, 242, 242), Operator:=xlFilterCellColor
            .Range("Z1:Z600000").SpecialCells(xlCellTypeVisible).Value = 1
            .AutoFilterMode = False
            .Range("B1:A600000").AutoFilter Field:=1, Operator:=xlFilterNoFill
            .Range("Z1:Z600000").SpecialCells(xlCellTypeVisible).Value = 0
            .AutoFilterMode = False
        End With
        
        Application.ScreenUpdating = False
    
    End Sub
    Palmetto

    Do you know . . . ?

    You can leave feedback and add to the reputation of all who contributed a helpful response to your solution by clicking the star icon located at the left in one of their post in this thread.

  2. #2
    Registered User
    Join Date
    05-07-2010
    Location
    Cayman Islands
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: script to write 1's and zero's for cell color

    Thank you, you guys are great.
    I have to know is there any way to do this with one pass?

    Find the unique and first instance and then place the ones for those and 0’s for the duplicates?

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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