+ Reply to Thread
Results 1 to 16 of 16

Random colour change on cell content input

  1. #1
    Forum Contributor
    Join Date
    08-04-2008
    Location
    West Calder, Scotland
    MS-Off Ver
    365
    Posts
    430

    Random colour change on cell content input

    Hi

    I have a spreadsheet where we insert the time when a driver books out to start their delivery route.

    I am looking for a way where a cell will randomly turn red to indicate the vehicle is to be searched before departure. There is a need for a minimum 5 searches and the route numbers to be noted
    Thank you for you help
    Attached Files Attached Files
    Last edited by JamesT1; 04-03-2010 at 10:54 PM.

  2. #2
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,375

    Re: Random colour change on cell content input

    Try the attached. It works without a macro, rather with 5 random numbers that are re-calculated every time a cell is changed.

    Based on that, there is conditional formatting applied to the yellow cells, so they turn red when their route number is in the list of the 5 random numbers.

    You will need to install and activate the Analysis ToolPak for the randbetween() function to work. See here http://office.microsoft.com/en-us/ex...092301033.aspx
    Attached Files Attached Files

  3. #3
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: Random colour change on cell content input

    Slight mod to Teylyn's formula in column-J - just using the COUNTA function to set the upper limit for the RANDBEWTEEN function. This will limit the upper boundary to the number of routes in the table.

    Note: the count is adjusted to compensate for header/blanks rows per the sample workbook. You may need to adjust the formula for this if the real workbook is different.

    =RANDBETWEEN(1,COUNTA(B:B)-3)
    Palmetto

    Do you know . . . ?

    You can leave feedback and add to the reputation of all who contributed a helpful response to your solution by clicking the star icon located at the left in one of their post in this thread.

  4. #4
    Forum Contributor
    Join Date
    08-04-2008
    Location
    West Calder, Scotland
    MS-Off Ver
    365
    Posts
    430

    Re: Random colour change on cell content input

    Thanks for your help and pointing me in the right direction guys,

    My fault for not being totaly clear in my original post. Each time I input a time and move to another cell the random numbers change, including highlighting routes that have previously departed.

    what I need is a way for a route number cell to randomly go red as we insert the time when a driver books out
    Last edited by JamesT1; 04-03-2010 at 01:37 PM.

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Random colour change on cell content input

    Once you enter a value in depart time, it goes red (or not). It that alone sufficient, or does it need to stay red as other cells are filled?
    Entia non sunt multiplicanda sine necessitate

  6. #6
    Forum Contributor
    Join Date
    08-04-2008
    Location
    West Calder, Scotland
    MS-Off Ver
    365
    Posts
    430

    Re: Random colour change on cell content input

    Hi Shg

    The cell doesn't need to stay red,,,,,,we need to randomly search 5 vehicles from the list as the drivers book out,,,,, what I need is 5 route cells to turn red randomly as the depart time is inserted

  7. #7
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: Random colour change on cell content input

    Try this formula for the conditional format. It will look for a number entry and well as match the route number.

    =AND(ISNUMBER(D4),NOT(ISNA(MATCH(B4,$J$4:$J$8,0))))
    There is a possibility that you won't get five matches, but if there are time values in the cells then just press the F9 key to force a new set of random numbers to generate different matches.

  8. #8
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,375

    Re: Random colour change on cell content input

    James,

    The cell doesn't need to stay red,,,,,,we need to randomly search 5 vehicles from the list as the drivers book out,,,,, what I need is 5 route cells to turn red randomly as the depart time is inserted
    That's what my suggestion does. I'm not sure I understand what's not working for you.

  9. #9
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Random colour change on cell content input

    T, I think James wants it to change (or not) as a value is entered in the depart time column, not en masse.

  10. #10
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Random colour change on cell content input

    I'd like to go on record as saying that this seems like an unnecessarily complex solution, but I'm not seeing anything simpler.

    Clearing one or more cells in the Depart column will clear the corresponding Search column. Other than clearing, you can only change one cell in the Depart column at a time. When they are all filled in, "Search" will have appeared exactly five times (the constant nSrch in the code, which you can change as desired).

    The table is dynamic, and will adapt to varying numbers of rows according to the last number in the Start Time column. Do Insert > Name > Define to see (or Name Manager in Excel 2007).

    The code below is in the sheet module in the attachment.
    Please Login or Register  to view this content.
    Attached Files Attached Files

  11. #11
    Forum Contributor
    Join Date
    08-04-2008
    Location
    West Calder, Scotland
    MS-Off Ver
    365
    Posts
    430

    Re: Random colour change on cell content input

    Hi Guys

    Thank you all for your help,,

    shg

    this works works exactly as I need it,,,,, your reading of what I need is correct

    teylyn

    the problem with the 'randbetween', it changed all the routes(as shg said,'en masse') to be searched each time a driver booked out and a new cell was selected

    your help and time is very much appreciated. I apologise if I wasn't exactly clear in my original post
    Last edited by JamesT1; 04-03-2010 at 10:56 PM.

  12. #12
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,375

    Re: Random colour change on cell content input

    Well, you could just ignore the color changes and only search those vehicles that are marked red after the last time is filled in. But I can see how the constant change of red to normal can be distracting.

    Another possibility might be to turn off automatic calculation, fill in all your values, then hit F9 to see 5 rows light up.

    cheers

  13. #13
    Forum Contributor
    Join Date
    08-04-2008
    Location
    West Calder, Scotland
    MS-Off Ver
    365
    Posts
    430

    Re: Random colour change on cell content input

    Hi Folk

    below is the code kindly supplied by shg to randomly highlight the cells when a driver books out....... it works like a dream

    as both the 'Depart Time and Search' columns are unlocked for this process is there a way to stop the information in the 'Search Column' being deleted after it indicates which vehicles are to be searched

    Please Login or Register  to view this content.
    many thanks for your help

  14. #14
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Random colour change on cell content input

    You want to keep the user from clearing the word "Search", or keep him/her from clearing the departure time once entered (which also clears "Search")

  15. #15
    Forum Contributor
    Join Date
    08-04-2008
    Location
    West Calder, Scotland
    MS-Off Ver
    365
    Posts
    430

    Re: Random colour change on cell content input

    Hi shg

    preferably once the time is entered it cannot be deleted, which would also include the search indication

  16. #16
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Random colour change on cell content input

    Try this.

    The sheet password is Bob. Change that in the code as desired.

    Excel security is for convenience in honest people avoiding mistakes, not miscreants trying to break things. Sheet passwords are laughably easy to break. In addition, anyone could look in the code to see the password. You could circumvent that by putting a password on the VBA project, but they could still get the sheet password.

    Keep that in mind.
    Attached Files Attached Files

+ 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