Results 1 to 7 of 7

For Each Loop code issue

Threaded View

  1. #1
    Registered User
    Join Date
    05-05-2014
    Location
    Denver, CO
    MS-Off Ver
    O365
    Posts
    4

    For Each Loop code issue

    I know this code is very rough, I am very rusty, the 90s seem so recent. I cannot get the macro below to execute properly. It should go through each cell in a defined range read the value and change the cell background to correspond. The If Then nest works properly for each active cell, but cannot get it to loop through the range. Thank you in advance

    Sub Color()
    ' Changes the cell color to correspond to the letter grade
    Dim Grade As Range
    Set Grade = Range("L16:L33").Text
    Grade.Select
        
       For Each Cell In Grade
       
       If Cell.Value = "A" Then
       
        With Selection.Interior
            .Pattern = xlSolid
            .PatternColorIndex = xlAutomatic
            .Color = 5287936
            .TintAndShade = 0
            .PatternTintAndShade = 0
        End With
      End If
      
      If Cell = "C" Then
       
        With Selection.Interior
            .Pattern = xlSolid
            .PatternColorIndex = xlAutomatic
            .Color = 65535
            .TintAndShade = 0
            .PatternTintAndShade = 0
        End With
      End If
      
      Next Cell
        
    End Sub
    Last edited by alansidman; 05-06-2014 at 10:02 AM. Reason: code tags

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Issue with For Each loop
    By ATLGator in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 07-16-2012, 09:01 PM
  2. For Loop Issue
    By pr4t3ek in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-12-2008, 10:40 AM
  3. Do while loop issue
    By Licquor in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-29-2008, 11:19 AM
  4. Loop issue
    By punter in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-13-2007, 03:18 PM
  5. Issue with Do Loop
    By Linking to specific cells in pivot table in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-24-2005, 06:05 PM

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