+ Reply to Thread
Results 1 to 6 of 6

Case Code For changing Cell Color

  1. #1
    Registered User
    Join Date
    08-24-2010
    Location
    Newcastle, England
    MS-Off Ver
    Excel 2003
    Posts
    8

    Case Code For changing Cell Color

    Hi,

    I am trying to create a Bar bending Schedule for construction sites. I am using VBA to help restrict and guide the users in what they are doing.

    I have attached the spreadsheet I am working on to help.

    I have compiled a Case statement which I want it to change the colour of particular cells based on the value entered into another cell as long as the cell has not data imputed

    E.g.

    If I enter 21 into cell I12 then Cell L12 will turn to index colour 41 if the cell is empty, the reason for this is that the blue cell is indicating it’s the last cell for a value to be entered the remaining cells are to remain blank. Now once I enter I value in cell L12 I’d want what ever text that is place to be place in ( ) and for the cell to return to index colour 2. (On the spread sheet I have manually indicated what I want)

    the code I am using to change the colour of the cells is:

    Please Login or Register  to view this content.
    Can anyone help me with this please?
    Attached Files Attached Files
    Last edited by ASnowball; 08-26-2010 at 06:29 AM.

  2. #2
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Case code!

    Put his macro in the module of sheet1.

    Please Login or Register  to view this content.

  3. #3
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Case code!

    Your post does not comply with Rule 1 of our Forum RULES. Your post title should accurately and concisely describe your problem, not your anticipated solution. Use terms appropriate to a Google search. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will be addressed according to the OP's experience in the forum: If you have less than 10 posts, expect (and respond to) a request to change your thread title. If you have 10 or more posts, expect your post to be locked, so you can start a new thread with an appropriate title.
    To change a Title on your post, click EDIT then Go Advanced and change your title, if 2 days have passed ask a moderator to do it for you.
    Hope that helps.

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

    Free DataBaseForm example

  4. #4
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Case code!

    Try this workbook.

    1/. I have added a sheet with your shape codes listed, and added a dynamic named range "Shape_Codes" based on this list.
    The list is numeric but formatted as Custom > "#,#00" this allows the dropdown list I have added to sheet "Bar Schedule" to display as "00", "01", etc...

    You can add or subtract from this list as you wish, but the list should not contain any blanks.

    2/. This code is added to the sheet module for Sheet "Bar Schedule", not the workbook module as in your sample.
    Please Login or Register  to view this content.
    Note that the Target.value is numeric and not text as displayed.

    This code can be improved on, but let's see if it does what you want first.

    3/. I have removed your "Before Save" Code from the sample for testing purposes.
    (I suspect that this code should also be in a sheet module.)


    Hope this helps
    Attached Files Attached Files
    If you need any more information, please feel free to ask.

    However,If this takes care of your needs, please select Thread Tools from menu above and set this topic to SOLVED. It helps everybody! ....

    Also
    اس کی مدد کرتا ہے اگر
    شکریہ کہنے کے لئے سٹار کلک کریں
    If you are satisfied by any members response to your problem please consider using the small Star icon bottom left of their post to show your appreciation.

  5. #5
    Registered User
    Join Date
    08-24-2010
    Location
    Newcastle, England
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: Can't Get My Case Code For changing Cell Color to Work

    snb & RoyUK,

    thank you both very much both codes worked :-), flexibilty purposes & to allow for change in future shape codes i used RoyUK.

    As you can see i'm pretty new to VBA and still don't know how condense my codes as well as you both are able to do, oh and get them to work haha.

    Again thank you very much.

  6. #6
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Can't Get My Case Code For changing Cell Color to Work

    You might want to consider this, it allows for multiple deletions and fill down in Range("I12:I42")

    It might just be a little more useable
    Please Login or Register  to view this content.

    Hope this helps
    Last edited by Marcol; 08-26-2010 at 07:26 AM. Reason: Added error handler to code

+ 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