Results 1 to 11 of 11

Cell Shading Macro Depending on Text

Threaded View

BluTalon Cell Shading Macro Depending... 05-30-2008, 07:19 PM
rylo Hi Try this Sub aaa()... 05-30-2008, 07:42 PM
Shijesh Kumar Hi. Try this code, it... 05-30-2008, 07:45 PM
Leith Ross Hello BluTalon, This... 05-30-2008, 08:11 PM
BluTalon oops. I'm sorry. Both seem... 05-30-2008, 08:32 PM
jindon Sub test() Dim i As Long,... 05-30-2008, 09:23 PM
Leith Ross Hello BluTalon, To skip... 05-30-2008, 09:28 PM
royUK Why not use Conditional... 05-31-2008, 03:24 AM
  1. #1
    Registered User
    Join Date
    01-10-2008
    Posts
    44

    Cell Shading Macro Depending on Text

    Hi there.

    I will have a spreadsheet similar to the image provided. Basically, I need the macro to go row by row down column I. If the cell in column I contains the word "Tech" I need the cells from column B to P to be shaded color1; if it contains "Update," color 2; if the cell is blank; leave the cell as is. Once the macro has done this, it will continue to the next row and to the same check.

    The number of rows in the spreadsheet will change on a day-to-day basis depending on the data that's pulled, but the columns should remain the same.

    So I think I have the shading part. This is what I have so far. I'm not sure if this is the most efficient way of coding it, but it kinda works. I guess another problem would be if in the future the column with this info (column I) changes and shifts.


    Sub Shading()
    
    ActiveSheet.Range("I3").Select
    
    
    If Range("I3") = "Tech" Then
        Range("C3:P3").Select
        With Selection.Interior
            .ColorIndex = 36
            .Pattern = xlSolid
        End With
    ElseIf Range("I3") = "Updates" Then
        Range("C3:P3").Select
        With Selection.Interior
            .ColorIndex = 34
            .Pattern = xlSolid
        End With
    End If
    
    End Sub

    I've been trying to figure something out, but I haven't been able to wrap my brain on how to do this.

    Thanks to all for any help you can provide.
    Attached Files Attached Files

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