+ Reply to Thread
Results 1 to 11 of 11

compare column a with Column a

  1. #1
    Registered User
    Join Date
    06-03-2009
    Location
    philippines
    MS-Off Ver
    Excel 2003
    Posts
    9

    compare column a with Column a

    Excel Macro:

    Is there a way to show the exact message (Message column) after clicking a COMMAND Button?

    Column B
    B2: Yes
    B3: No
    B4:

    Column C
    C2: No
    C3:
    C4: No


    Column D (Message)
    D2:Column B is not required
    D3: Column C is requred
    D4: Column B is requred

    Thank you
    Last edited by artbishop; 06-04-2009 at 11:49 PM.

  2. #2
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,885

    Re: compare column a with Column a

    Hi Artbishop, and welcome to the forum.

    You lost me. While that's done quite easily, I'd recommend posting a sample workbook with your data/layout, and then show the expected results (or try explaining it better). Your title says to compare column A to column A, yet you don't reference column A in your thread.

  3. #3
    Registered User
    Join Date
    06-03-2009
    Location
    philippines
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: compare column a with Column a

    Hi Paul...


    attached is the sample excel file...

    the column D (message) will only show after clicking the COMMAND Button..thaNKS
    Attached Files Attached Files

  4. #4
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,885

    Re: compare column a with Column a

    Ok, still lost.

    You click a command button and some text appears in column D. How do I know what text is supposed to appear in column D, and in what cell(s)?

    Currently there's messages in column D, and I'm assuming that they are somehow related to the values in columns B and C, but you're going to have to define it better.

    For example:

    If B2 is "Yes" and C2 is "No", when you click the command button D2 should say "Column C is not required".
    If B2 is blank and C2 is blank, the message should say __________
    If B2 is blank and C2 is "Yes", ________

    Get the picture?

    By clicking a command button we can have excel say anything we want, but there has to be rules.

  5. #5
    Registered User
    Join Date
    06-03-2009
    Location
    philippines
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: compare column a with Column a

    The messages in column D are related to the values in columns B and C.

    If B2 is "Yes" and C2 is "No", when you click the command button D2 should say "Column C is not required".
    If B2 is "No" and C2 is blank, the message should say "Column C is required"
    If B2 is blank and C2 is "No", the message should say "Column B is required"


    thanks

  6. #6
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,885

    Re: compare column a with Column a

    Are there any other options? What if B2 is "No" and C2 is "No", or C2 is "Yes"? What if B2 is "Yes" and C2 is Blank?

    If only the examples you provided result in a message, great, we can add that rule to the code.

    Also, do you want the command button to loop through all used rows (all rows that have values in columns B and C) and update column D accordingly? Or do you want to only run it on one row at a time (the currently selected row, for example)?

  7. #7
    Registered User
    Join Date
    06-03-2009
    Location
    philippines
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: compare column a with Column a

    Are there any other options? No other option


    Also, do you want the command button to loop through all used rows (all rows that have values in columns B and C) and update column D accordingly?

    Yes, please

  8. #8
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,885

    Re: compare column a with Column a

    First, a non-programming method would be to put the following formula in D2 and copy it down as many rows as you need:

    =IF(AND(B2="",C2=""),"",IF(AND(B2="Yes",C2="No"),"Column C is not required",IF(AND(B2="No",C2=""),"Column C is required",IF(AND(B2="",C2="No"),"Column B is required",""))))

    With this in mind, do you still need a command button and macro?

  9. #9
    Registered User
    Join Date
    06-03-2009
    Location
    philippines
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: compare column a with Column a

    yes, i still need a command button with macros

  10. #10
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,885

    Re: compare column a with Column a

    Then try this...

    Double-click on your command button to open the VB Editor window. Copy and paste the following code into that window, then close the VB Editor. On the Visual Basic toolbar, click the Design Mode icon to take your sheet out of design mode. You can then click on your command button and it should fill the appropriate messages in column D.
    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    06-03-2009
    Location
    philippines
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: compare column a with Column a

    great thanks much

+ 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