+ Reply to Thread
Results 1 to 12 of 12

Calculations based on priorities

  1. #1
    Registered User
    Join Date
    04-18-2012
    Location
    no
    MS-Off Ver
    Excel 2007
    Posts
    47

    Question Calculations based on priorities

    Hello,

    Can someone help with the following please?:

    Im trying to do a calculation using a macro. When the user selects the "Make Appointment before" field,
    it should automatically calcutate the days left to make an appointment, when the "Refresh" button is clicked.
    The calculation is done by first checking the priority and then subtracting registered date from todays date (All data in "Data" sheet)

    If the priority is A the user has a maximum of 3 days to create an appointment.
    If the priority is B the user has a maximum of 7 days to create an appointment.
    If the priority is C the user has a maximum of 14 days to create an appointment.

    If its gone past the days it should say how many days behind and change font to bold with minus"-" sign e.g. -1

    Also if there's no registered date in data, it should say "No registered date"

    Please see attached. Thanks in advance

    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591

    Re: Calculations based on priorities

    Hi

    As an example, put Make Appointment Before in D4, and Priority in E4. Then run your refresh macro so that it brings back the priority.

    If you put the formula
    Please Login or Register  to view this content.
    in D5, change the number format to be General, and copy down to D12, does it give you the correct value you want for those items that do have a valid date registered?

    rylo

  3. #3
    Registered User
    Join Date
    04-18-2012
    Location
    no
    MS-Off Ver
    Excel 2007
    Posts
    47

    Re: Calculations based on priorities

    Hello,

    Thanks for your response

    Using your formula I'm able to get the correct value I want for the items that do have a valid date registered

  4. #4
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591

    Re: Calculations based on priorities

    Hi

    So does that mean you have got your question solved?

    rylo

  5. #5
    Registered User
    Join Date
    04-18-2012
    Location
    no
    MS-Off Ver
    Excel 2007
    Posts
    47

    Re: Calculations based on priorities

    Hello,

    Thanks for your response

    It's not really solved, as I dont want the user to have to write the formula.
    I want the user to select the "Make Appointment Before" field and put it in any column and when the user hits the Refresh button the days show up.
    Also, the user doesn't have to select the priority column. Like the calculation should be done in the "Data" Sheet and the answer shown in the "Make Appointment Before" field.
    Hopefully that makes sense

    Also, if you dont mind, can you tell me what the "2" does in your formula.

    Please Login or Register  to view this content.


    Thanks

  6. #6
    Registered User
    Join Date
    04-18-2012
    Location
    no
    MS-Off Ver
    Excel 2007
    Posts
    47

    Re: Calculations based on priorities

    Bump......

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

    Re: Calculations based on priorities

    can you tell me what the "2" does in your formula.
    Help is handy for answering questions like that:

    VLOOKUP

    Searches for a value in the first column of a table array and returns a value in the same row from another column in the table array.

    The V in VLOOKUP stands for vertical. Use VLOOKUP instead of HLOOKUP when your comparison values are located in a column to the left of the data that you want to find.

    Syntax
    VLOOKUP(lookup_value,table_array,col_index_num,range_lookup)

    Lookup_value The value to search in the first column of the table array (array: Used to build single formulas that produce multiple results or that operate on a group of arguments that are arranged in rows and columns. An array range shares a common formula; an array constant is a group of constants used as an argument.). Lookup_value can be a value or a reference. If lookup_value is smaller than the smallest value in the first column of table_array, VLOOKUP returns the #N/A error value.

    Table_array Two or more columns of data. Use a reference to a range or a range name. The values in the first column of table_array are the values searched by lookup_value. These values can be text, numbers, or logical values. Uppercase and lowercase text are equivalent.

    Col_index_num The column number in table_array from which the matching value must be returned. A col_index_num of 1 returns the value in the first column in table_array; a col_index_num of 2 returns the value in the second column in table_array, and so on. If col_index_num is:

    Less than 1, VLOOKUP returns the #VALUE! error value.
    Greater than the number of columns in table_array, VLOOKUP returns the #REF! error value.
    Entia non sunt multiplicanda sine necessitate

  8. #8
    Registered User
    Join Date
    04-18-2012
    Location
    no
    MS-Off Ver
    Excel 2007
    Posts
    47

    Re: Calculations based on priorities

    Thanks shg for your help

  9. #9
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591

    Re: Calculations based on priorities

    Hi

    Update your Refresh code to be
    Please Login or Register  to view this content.

    Open your form, and put in a Make Appointment Before column Heading and close out the form.

    Then press your refresh button. See how that goes. It doesn't do the formatting that you specifically want, and it doesn't handle the situation where you have a blank date registered, but hopefully it will get you going.

    rylo

  10. #10
    Registered User
    Join Date
    04-18-2012
    Location
    no
    MS-Off Ver
    Excel 2007
    Posts
    47

    Re: Calculations based on priorities

    Hello Rylo,

    Thanks a lot for your help.

    I have one more query and think I can figure out the rest myself.
    When I take out "Date Registered" I get an error saying "Object variable or with block variable not set". I tried changing the code but I'll either get an error or no values, I'm not sure how to fix it

  11. #11
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591

    Re: Calculations based on priorities

    Hi

    The formula assumes that you have the Date Registered as a field in the final sheet. If, like the priority it may not exist, then you will have to modify the formula to find it on the data sheet in the same way that I updated the formula to find the priority in the data sheet based on the First Name. You will need to have some sort of unique key that "MUST" be on the final sheet so you can find any required data.

    rylo

  12. #12
    Registered User
    Join Date
    04-18-2012
    Location
    no
    MS-Off Ver
    Excel 2007
    Posts
    47

    Re: Calculations based on priorities

    Hello,

    Thanks for your help, I'm able to get it working now.

    plank

+ 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