+ Reply to Thread
Results 1 to 12 of 12

Need Script to fill Cell based on the cell value

  1. #1
    Registered User
    Join Date
    10-06-2011
    Location
    India, Chennai
    MS-Off Ver
    Excel 2003 (in Office) Excel 2007 (in Home)
    Posts
    21

    Need Script to fill Cell based on the cell value

    Hi,

    I am very new to Excel, kindly help me..

    I have a column in my excel in sheet2, in that i have totally 5 levels, i want to fill each cell with a color based on the cell content.

    exact scenario.

    Column E. (it contains 5,4,3,2,1,0 in many rows).

    If a cell in column E has content 5 then it has to be filled with RED.
    If a cell in column E has content 4 then it has to be filled with ORANGE.
    If a cell in column E has content 3 then it has to be filled with GOLD.
    If a cell in column E has content 2 then it has to be filled with YELLOW.
    If a cell in column E has content 1 then it has to be filled with LIGHT YELLOW..


    can any 1 give me a script that will do this process automatically ...thank you in advance..

    I need this to prepare a report daily,...
    Last edited by dineshsilicon; 10-06-2011 at 11:55 AM. Reason: left some info

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Need Script to fill Cell based on the cell value

    Hi,

    One way

    Please Login or Register  to view this content.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    10-06-2011
    Location
    India, Chennai
    MS-Off Ver
    Excel 2003 (in Office) Excel 2007 (in Home)
    Posts
    21

    Re: Need Script to fill Cell based on the cell value

    Hi
    Thanks for your quick response,. but its showing error...


    Sub ColourCells()
    Dim r As Range, rCell As Range
    Set r = Range(Sheet2.Range("E1"), Sheet2.Range("E" & Rows.Count).End(xlUp))

    For Each rCell In r

    Select Case rCell.Value
    Case Is = 5
    rCell.Interior.ColorIndex = 3
    Case Is = 4
    rCell.Interior.ColorIndex = 46
    Case Is = 3
    rCell.Interior.ColorIndex = 44
    Case Is = 2
    rCell.Interior.ColorIndex = 6
    Case Is = 1
    rCell.Interior.ColorIndex = 36
    End Select
    Next rCell


    End Sub

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Need Script to fill Cell based on the cell value

    Hi,

    Do you have a sheet with the code name (not tab name) "Sheet2"

  5. #5
    Registered User
    Join Date
    10-06-2011
    Location
    India, Chennai
    MS-Off Ver
    Excel 2003 (in Office) Excel 2007 (in Home)
    Posts
    21

    Re: Need Script to fill Cell based on the cell value

    could u pls give me ur mail id,, i will send the xl now.. not able to upload here shoing database error......tomorrow also i have to work with many excel sheets to sort this,, so only need this....

    pld give ur email id i will send u the exact xl sheet am working with

  6. #6
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326

    Re: Need Script to fill Cell based on the cell value

    Solving problems via e mail is ,not our way of doing things.

    Also remember everybody here works on his spare time. Therefore if you need urgent answers you might want to search for paying XL services

  7. #7
    Registered User
    Join Date
    10-06-2011
    Location
    India, Chennai
    MS-Off Ver
    Excel 2003 (in Office) Excel 2007 (in Home)
    Posts
    21

    Re: Need Script to fill Cell based on the cell value

    OH i just attached the excel sheet am working with, could u pls chk it annd reply me,,,tomorrow i have 147 file like this to sort,, so only posting here and there to get a script.. sorry
    Attached Files Attached Files

  8. #8
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Need Script to fill Cell based on the cell value

    Hi,

    Please answer the question I asked.
    Then, if you still have a problem upload the file here. I've just uploaded several files wihout any database errors.

    Please try to avoid text speak in this forum.

  9. #9
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326

    Re: Need Script to fill Cell based on the cell value

    Your post does not comply with Rule 8 of our Forum RULES. Cross-posting is when you post the same question in other forums on the web. You'll find people are disinclined to respond to cross-posts because they may be wasting their time solving a problem that has been solved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser)to the cross-post. Expect cross-posts without a link to be closed a message will be posted by the moderator explaining why. We are here to help so help us help you!

    Read this to understand why we ask you to do this

    http://www.mrexcel.com/forum/showthread.php?t=583829

  10. #10
    Registered User
    Join Date
    10-06-2011
    Location
    India, Chennai
    MS-Off Ver
    Excel 2003 (in Office) Excel 2007 (in Home)
    Posts
    21

    Re: Need Script to fill Cell based on the cell value

    I am very sorry, i was very new to forums and this is my first forum in internet, hereafter i wont repeat the same. Thank you for making me understand.

  11. #11
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Need Script to fill Cell based on the cell value

    Hi,
    How do you expect it to work if you haven't actually copied the macro procedure I gave you into the workbook?

    I've now added and run it. See the attached
    Attached Files Attached Files

  12. #12
    Registered User
    Join Date
    10-06-2011
    Location
    India, Chennai
    MS-Off Ver
    Excel 2003 (in Office) Excel 2007 (in Home)
    Posts
    21

    Re: Need Script to fill Cell based on the cell value

    Sir,

    Working perfectly now, thanks a lot for ur valuable time. have a good day. thanks again

+ 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