+ Reply to Thread
Results 1 to 11 of 11

Macro to compare two column return OK or Check.

  1. #1
    Registered User
    Join Date
    02-08-2009
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    80

    Macro to compare two column return OK or Check.

    Hi

    I need to write a macro to compare column between two sheet and return "Check" or "OK".

    MACRO ISSUE.jpg

    I have a button on sheet 3, when i press it i would like to check value in cell E4 and match it against sheet 2 cell G7. If it match return ok else check.

    one this loop is done then go done 1 cell and do the same untill no more entry found to compare.

    I have attache image.

    Please can someone help me.

  2. #2
    Valued Forum Contributor AlvaroSiza's Avatar
    Join Date
    09-19-2007
    Location
    Staffordshire
    MS-Off Ver
    2007
    Posts
    591

    Re: Macro to compare two column return OK or Check.

    It would be a lot easier if you could provide a sample workbook.
    Perhaps it was the Noid who should have avoided me...
    If you are satisfied with my solution click the small star icon on the left. Thanks
    1. Make a copy of your workbook and run the following code on your copy (just in case)
    2. With excel open, press ALT+F11 to open the Visual Basic Editor (VBE). From the "Insert" menu, select "Module".
    3. Paste the code from above into the empty white space. Close the VBE.
    4. From the developer tab, choose "Macros", select the Sub Name, and click "Run".

  3. #3
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Macro to compare two column return OK or Check.

    How do you want to return "Check" or "OK"?

  4. #4
    Registered User
    Join Date
    02-08-2009
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    80

    Re: Macro to compare two column return OK or Check.

    HI I have attached file

    On file i have two sheet as follows;

    "Check Employee Hours"
    "Check Hours"

    I want to compare "Check Hours" against "Check Employee Hours".

    On Check Hours sheet user keys in Start Time, End time and Break Time. Once times are keyed in then user will press the button on "SUNDAY"

    This is where i need help with macro.

    When user press the button, i want to check column "E" time aginst the sheet "check employee hours" column "G" if time matchs i want "OK" else "Check" displayed in column "E" on check hours.

    Please can you help me.

    Regards
    Attached Files Attached Files

  5. #5
    Valued Forum Contributor AlvaroSiza's Avatar
    Join Date
    09-19-2007
    Location
    Staffordshire
    MS-Off Ver
    2007
    Posts
    591

    Re: Macro to compare two column return OK or Check.

    Not difficult. However, what you are requesting will blow through the formulas currently in place in Column E. This would mean they would be unavailable in a reuse scenario (which I presume is what you are attempting). How about putting the "OK" or "Check" in a new column, one to the right of "E"?

  6. #6
    Forum Contributor thameem127's Avatar
    Join Date
    04-06-2012
    Location
    Jeddah,Saudi Arabia
    MS-Off Ver
    Excel 2003,Excel 2007
    Posts
    321

    Re: Macro to compare two column return OK or Check.

    Please explain your workbook clearly what is EFC T& A

  7. #7
    Registered User
    Join Date
    02-08-2009
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    80

    Re: Macro to compare two column return OK or Check.

    Quote Originally Posted by AlvaroSiza View Post
    Not difficult. However, what you are requesting will blow through the formulas currently in place in Column E. This would mean they would be unavailable in a reuse scenario (which I presume is what you are attempting). How about putting the "OK" or "Check" in a new column, one to the right of "E"?
    I am ok with macro over riding the formula in column "E" would prefer this

    BUT

    if you think its easier to put the macro on right of column "E" i dont mind this either.

  8. #8
    Registered User
    Join Date
    02-08-2009
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    80

    Re: Macro to compare two column return OK or Check.

    Hi

    Please can someone help me with the macro

    I am trying to write but not have any luck been try since last week.

    Any help appricated.

    Regards

  9. #9
    Valued Forum Contributor
    Join Date
    03-29-2013
    Location
    United Kingdom
    MS-Off Ver
    Office/Excel 2013
    Posts
    1,749

    Re: Macro to compare two column return OK or Check.

    Hi Coolhit

    try this and see if it's what you need..

    Compare Macro Try.xls
    Elegant Simplicity............. Not Always

  10. #10
    Registered User
    Join Date
    02-08-2009
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    80

    Re: Macro to compare two column return OK or Check.

    Quote Originally Posted by AndyLitch View Post
    Hi Coolhit

    try this and see if it's what you need..

    Attachment 231623

    Hi Andy

    Thank you for helping me.

    I have pressed the button there is an error. Adam A had 240 min on both sheet it should display OK but it says CHECK

    Please advice.

  11. #11
    Valued Forum Contributor
    Join Date
    03-29-2013
    Location
    United Kingdom
    MS-Off Ver
    Office/Excel 2013
    Posts
    1,749

    Re: Macro to compare two column return OK or Check.

    Compare Macro Try.xls

    Found a couple of problems
    1. The hours displayed on one sheet had different number formatting which was misleading
    2. A direct comparison of the numbers on either worksheet didn't work because the was a .000000000000000001 difference.

    Now you just need to consider the 30 min breaks

+ 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