+ Reply to Thread
Results 1 to 6 of 6

Streamlining IF command

  1. #1
    Registered User
    Join Date
    05-29-2012
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    4

    Streamlining IF command

    Hi.

    Firstly, I have tried a search to no avail, but I am not even sure if I am using the right terms to be honest.
    I have an excel spreadsheet, it is actually a roster. Shift times are variable but each day three cells will be coloured differently (so one purple, one blue, one green) and the others all white.
    I am looking for a formula that will display the person in colour x for that day.
    I have had some success making a function for background colour from the internet, and I can use the IF function for up to 8 of the 10 columns but it then hits the length limit. (Excel 2010) It also seems very unwieldy and would be hard to change easily. I am sure there is a better way of doing this, or by making a VBA function.
    My spreadsheet is Columns for person and rows for each day of the week, so below is what I have so far (the person's name is on Row 5):
    Please Login or Register  to view this content.
    The VBA function (from a website) is
    Please Login or Register  to view this content.
    Is anyone able to offer any help please?

    Thanks,
    Jon
    Attached Files Attached Files
    Last edited by cynicor; 05-30-2012 at 08:47 PM.

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,612

    Re: Streamlining IF command

    Hi Jon/cynicor, welcome to the forum. Please take a moment to read the forum rules and then add code tags around your codeHi cynicor, welcome to the forum. Please take a moment to read the forum [URL=
    Ben Van Johnson

  3. #3
    Registered User
    Join Date
    05-29-2012
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Streamlining IF command

    Thank you for your reply.

    I have now read the rules, edited the post and attached a sample of the workbook. The cell with the working formula is S18, but it can only extend to about 8 cells.

    Thank you for your time.

  4. #4
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,612

    Re: Streamlining IF command

    Try this macro instead of trying to do it with formulas:

    Please Login or Register  to view this content.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    05-29-2012
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Streamlining IF command

    Wow, that is amazing.

    Thank you for your help.

    In trying to solve my problem I tried to learn basic VBS and had made something that works, but it was extremely crude and could not scale. Your simple code looks like it will scale much more effectively.

    Do you mind explaining a little about how I would alter the on call names to be on their own sheet, if the roster was over 3 sheets?

    What I have, is the sample worksheet 3 times over on different sheets (so actually 30-35 people in 3 different areas) and in the end hope for the oncall to be a 4th worksheet that will be easier for people to read.

    In the meantime I will try to understand your code. I am getting the hang of the basics and think it will be a matter of tweaking the "range" values and to where the names actually display

    The sample below is a de-identified actual roster to illustrate.

    Thank you again for your help.
    Attached Files Attached Files
    Last edited by cynicor; 06-05-2012 at 01:30 AM. Reason: add attachment

  6. #6
    Registered User
    Join Date
    05-29-2012
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Streamlining IF command

    EDIT- NEVERMIND- I have fixed it. Was using Shifts when I should have used Shifts2.

    So using the code kindly posted above, I have altered it to obtain results on a larger roster. Only problem is it now does not work

    I just thought I needed to replicate the original code again, and have figured out how to extend the roster, add more people in, add another on call etc.

    The final part is making it work across multiple sheets. It seems to work almost completely but for some reason does not like to print the names of the person from the second sheet. It instead gives a runtime 91 error, and I can't figure out why.

    Any ideas?

    Please Login or Register  to view this content.
    Debugging highlights the last oncall4 offset line.

    Thanks!

    EDIT- NEVERMIND- I have fixed it. Was using Shifts when I should have used Shifts2.

    Thank you for such a helpful forum
    Attached Files Attached Files
    Last edited by cynicor; 06-06-2012 at 11:27 PM.

+ 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