+ Reply to Thread
Results 1 to 11 of 11

Code for If Condition

  1. #1
    Forum Contributor
    Join Date
    10-16-2010
    Location
    bangalore
    MS-Off Ver
    Excel 2019
    Posts
    288

    Code for If Condition

    Hi

    I have created Time tracker. in that associates are updating there time tracker for each transaction..but i want them not to end the transaction (End time) without updting column D,E,I and without updating these column that particular transaction should not be end..

    Please suggest..

    Attached the sheet for your reference
    Attached Files Attached Files
    Last edited by anwitha; 12-09-2010 at 04:31 AM.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Macro Code needed for If Conditioin

    Use Data Validation for this.

    1) Highlight G5:G124
    2) Select Data > Data Validation (you may have to hunt for this in xl07)
    3) Use the following settings:

    Validation Criteria:
    Allow: Custom

    Formula: =COUNTA($D5,$E5,$I5)=3


    You can use the Error Alert tab to create a more informative error message, if you want.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Forum Contributor
    Join Date
    10-16-2010
    Location
    bangalore
    MS-Off Ver
    Excel 2019
    Posts
    288

    Re: Macro Code needed for If Conditioin

    I have tried it in Data Validation as u have suggested above..but still its not working...Could u check this in my sample attached sheet and reply me?

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Code for If Condition

    I followed steps 1-3 as given exactly and it works. You not being able to follow 3 short steps is a very big concern.
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    10-16-2010
    Location
    bangalore
    MS-Off Ver
    Excel 2019
    Posts
    288

    Re: Code for If Condition

    Sir I have done the same thing as u suggegsted but it wasn't working..and again i have opened the sheet which you have attached but as soon as i opened this sheet i am getting the error dialogue box "Run Time Error - 438"

  6. #6
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Code for If Condition

    The error you are getting is coming the VBA in your workbook, not from the formula and the data validation I gave you. The VBA installed in your workbook is faulty in some way. Unfortunately the code is password protected so I can't suggest what the problem might be. Most likely some macro designed to run when the workbook is first opened is written incorrectly.

  7. #7
    Forum Contributor
    Join Date
    10-16-2010
    Location
    bangalore
    MS-Off Ver
    Excel 2019
    Posts
    288

    Re: Code for If Condition

    I have applied the formula and start working but even if D,E,I column is blank i am able to end the transaction buy clicking the stop button my query is it should not allow the user to stop until and unless they update these three column and also when the user completed the partulcar transaction and going fo next one by clicking start then the previous transaction colulmn should not be edited..here i have attached the sample sheet and also VBA code has been unprotected..Please check..
    Attached Files Attached Files

  8. #8
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Code for If Condition

    I'm having significant problems reading/using your sheet, something I don't usually have a problem with.

    1) Delete the two buttons and the code you have already created.
    2) Insert a single commandbutton
    3) Double-click the commandbutton to open the Sheet module for that button and paste in this code:
    Please Login or Register  to view this content.
    4) Edit the underlined part if needed to match the actual name of the commandbutton
    5) Close and save
    6) Try it
    Last edited by JBeaucaire; 12-09-2010 at 03:39 AM. Reason: code edited to add TIME TAKEN value in column H.

  9. #9
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Code for If Condition

    Here is the code in a new sheet, working fine for me...
    Attached Files Attached Files

  10. #10
    Forum Contributor
    Join Date
    10-16-2010
    Location
    bangalore
    MS-Off Ver
    Excel 2019
    Posts
    288

    Re: Code for If Condition

    Dear Jerry
    Its working fine.now...thanks a lot..

  11. #11
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Code for If Condition

    If that takes care of your need, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

+ 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