+ Reply to Thread
Results 1 to 7 of 7

Color code cell with case statement and datestamp cell(s) to the left

  1. #1
    Registered User
    Join Date
    04-06-2010
    Location
    San Diego, CA
    MS-Off Ver
    Excel 2003
    Posts
    16

    Color code cell with case statement and datestamp cell(s) to the left

    Hello,

    I've been wrestling with this code for quite some time which I got off of a forum that I'm trying to edit it without much luck. I have been searching this forum and others to find a solution. Currently, I'm using this code to color the cell based on a data validation list that works perfectly. I use this code so that I can copy/paste and autofill the values down, but I need a static datestamp that is inputted in the column to the left for each cell OR delete the date stamp if the cell is empty.

    I've tried to add a datestamp for each case and I must not understand VBA enough because it keeps crashing my Excel when I change the data validation list. I really believe there is something very simple that I'm not getting.

    Any help would be greatly appreciated

    Please Login or Register  to view this content.
    Last edited by garricko; 09-26-2010 at 08:40 PM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Color code cell with case statement and datestamp cell(s) to the left

    Hello garricko,

    You have made a very simple mistake. You have not disabled Events. When using either the Worksheet_Change or Worksheet_SelectionChange event, you should disable events before you do anything else. If you do not, you will create a cascade event and overflow the stack. Here is the amended code.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    04-06-2010
    Location
    San Diego, CA
    MS-Off Ver
    Excel 2003
    Posts
    16

    Re: Color code cell with case statement and datestamp cell(s) to the left

    Thanks Leith,

    However, how can I put the static date stamp to the cell to the left (column 22) in the vba and also keep the color formatting? That is my main problem.

    Sorry if I wasn't clear.

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Color code cell with case statement and datestamp cell(s) to the left

    Hello garricko,

    It looks like you want to change the conditional formatting of cell (if it exists) based on the contents of a cell in the range of "W11:W500" and then place a time stamp in the adjacent cell of column "U". Is that correct?

  5. #5
    Registered User
    Join Date
    04-06-2010
    Location
    San Diego, CA
    MS-Off Ver
    Excel 2003
    Posts
    16

    Re: Color code cell with case statement and datestamp cell(s) to the left

    Yes, actually column "V" to be exact. I know that I should probably be using "Offset" but I can't seem to get it to work.

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Color code cell with case statement and datestamp cell(s) to the left

    Hello garricko,

    If I understand the problem correctly, this revision should do what you want.
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    04-06-2010
    Location
    San Diego, CA
    MS-Off Ver
    Excel 2003
    Posts
    16

    Re: Color code cell with case statement and datestamp cell(s) to the left

    Thank you very much!

    I only had to change one thing which was to remove the "End If" because I got the "End If without the If block" error and now it works.

+ 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