+ Reply to Thread
Results 1 to 3 of 3

How to colour cells based on variable

  1. #1
    Registered User
    Join Date
    02-05-2013
    Location
    Sydney
    MS-Off Ver
    Excel 2010
    Posts
    3

    How to colour cells based on variable

    Hello All,

    I have just started with VBA and am having trouble with a basic problem of formatting a cells appearance based upon the value of a cell. For example I have the number 1 to 10 in a list and would like to format individual cells yellow if they have the value 5 and above, Once I have the VBA code basics I should be able to apply this to numerous sheets.

    Any help would be much appreciated.

    Jaso

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,615

    Re: How to colour cells based on variable

    The best start is to use the macro recorder. The forum can then help to clean up the code and generalize it.
    Ben Van Johnson

  3. #3
    Registered User
    Join Date
    02-05-2013
    Location
    Sydney
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: How to colour cells based on variable

    Thanks for getting back to me protonLeah. I've already tried playing around with the macro recorder however I'm not to sure how to get it to pick up "if" statements. This is what I have so far. I'm pretty sure the problem is I have the syntac all wrong... Any suggestions? (Note: I have number 1 to 10 in order in cells A1 to A10).

    Sub Using_If()
    If Range("A1:A10").Value >= 5 Then
    Range("A1:A10").Select
    With Selection.Interior
    .ColorIndex = 6
    .Pattern = xlSolid
    End With
    End If

    End Sub

+ Reply to Thread

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