+ Reply to Thread
Results 1 to 11 of 11

Cell Shading Macro Depending on Text

Hybrid View

  1. #1
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello BluTalon,

    To skip the header (1st row in the array), The "For R" loop needs to start at 2. I have made the change already. You can also change the column to check by changing the variable "C".
    Sub Shading()
    
      Dim C As Long
      Dim CI As Long
      Dim R As Long
      Dim Rng As Range
      
        C = 9   'Column "I"
    
        Set Rng = ActiveSheet.Cells(StartRow, C).CurrentRegion
        
          For R = 2 To Rng.Rows.Count
            Select Case Rng.Cells(R, C)
              Case Is = "Tech"
                CI = 36
              Case Is = "Update"
                CI = 34
              Case Else
                CI = xlNone
            End Select
            With Rng
              .Range(Cells(R, 1), Cells(R, .Columns.Count)).Interior.ColorIndex = CI
            End With
          Next R
        
    End Sub
    Sincerely,
    Leith Ross

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Why not use Conditional Formatting?

    See

    http://www.excel-it.com/excel_condit...formatting.htm
    Last edited by royUK; 05-31-2008 at 05:57 AM.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Valued Forum Contributor Shijesh Kumar's Avatar
    Join Date
    05-26-2008
    Location
    Bangalore / India
    MS-Off Ver
    2000
    Posts
    717
    opps...

    It totally slipped out of my mind...


    Yes we can use conditional formating...

    That would be easy as well to use

  4. #4
    Registered User
    Join Date
    01-10-2008
    Posts
    44
    The thing is that the file is exported as a *.tab originally. I then go ahead and have it saved as an *.xls. Also, a new *.tab file is created at least once a day.

    I didn't think I could use conditional formatting in this situation without having to enter all the criteria into each new file each time it was exported. Is this right?

  5. #5
    Registered User
    Join Date
    01-10-2008
    Posts
    44
    Just wanted to give a quick thanks for your help! The macro works great.

+ 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