+ Reply to Thread
Results 1 to 5 of 5

VB to color code Excel cells

  1. #1
    Registered User
    Join Date
    09-15-2012
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    3

    VB to color code Excel cells

    I have inherited an Excel Workbook and have never seen it before. It is a work schedule and employee names are entered into cells that represent what days they will work. I found a VB app for this worksheet that defines a range of cells and then runs an "if" statement that compares the value (name) of the cell to constant values in the statement and assigns a background color to that cell. My first task after receiving this is to enter the next work period schedule. To do this I copied the current work schedule and pasted it in to the right of the current work schedule. The problem I have is that the cells are no longer colored after I paste it but the font color was not lost. I checked the VB app and determined that I am within the range defined.

    I don't know VB so I am lost as to why I don't get color. Can anyone help me?

    See the attachment for VB code example and worksheet example showing what was copied (colored) and what was pasted (black & white).schedule example.docx

  2. #2
    Valued Forum Contributor WasWodge's Avatar
    Join Date
    08-02-2010
    Location
    Hampshire,England
    MS-Off Ver
    Office 365 and Office 2010
    Posts
    882

    Re: VB to color code Excel cells

    Can you post the actual sample spreadsheet.
    If you click the "Go Advanced" button then you will see a paperclip icon, if you click on that a box will appear that will allow you to attach the workbook.
    If my solution worked (or not) please let me know. If your question is answered then please remember to mark it solved

    Computers are like air conditioners. They work fine until you start opening windows. ~Author Unknown

  3. #3
    Registered User
    Join Date
    09-15-2012
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: VB to color code Excel cells

    Thanks for your help WasWodge. I have attached the problem sheet. It was part of a large workbook that has data I should not pass around. I copied this sheet out and into a new workbook. I hope everything went with it.
    Attached Files Attached Files

  4. #4
    Valued Forum Contributor WasWodge's Avatar
    Join Date
    08-02-2010
    Location
    Hampshire,England
    MS-Off Ver
    Office 365 and Office 2010
    Posts
    882

    Re: VB to color code Excel cells

    Just to update this post for anyone else reading this postI have PM'd the OP with a bit more detail of what I tested but the basic finding is that it is an issue with the sheet itself and not the code.

    I copied the data as values into another sheet and then put the code in that sheet and it runs correctly in the new sheet.

    I haven't managed to find out what is wrong with the original sheet.

  5. #5
    Registered User
    Join Date
    09-15-2012
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: VB to color code Excel cells

    Thanks again WasWodge for all your help. I have been able to create a new workbook and copy all the sheets from the old workbook into the new one and then create a new sheet with the VB code from the old sheet and I now have a working worksheet.

    I am considering this issue resolved and will mark it so as soon as I determine how to do that. This is my first time using this forum and I am very happy that I did.

+ 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