+ Reply to Thread
Results 1 to 17 of 17

IF A1 = Yes, then add 1 to B1

  1. #1
    Registered User
    Join Date
    04-29-2013
    Location
    Maryland, USA
    MS-Off Ver
    Excel 2010
    Posts
    50

    IF A1 = Yes, then add 1 to B1

    Hello, and thank you for looking.

    I wish to add 1 more to B1, if A1 = "yes."

    If A1 = "no," then B1 stays the same.

    The cells of Column A are updated everyday to "Yes" or "No." Column B cells only change if cell A = "Yes."

    Thanks, Jon

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,789

    Re: IF A1 = Yes, then add 1 to B1

    Please describe whether this event should happen only if any change in A1 cell alone Or the code should run on any cell in Column-A if there is any change?


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 365 on Win11 (365 on Win11 (desktop), 365 on Win11 (notebook)
    Posts
    8,207

    Re: IF A1 = Yes, then add 1 to B1

    Hi, Jon ,

    how is updated: by formula, by manual change directly to the cell, by Query?

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

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

    Re: IF A1 = Yes, then add 1 to B1

    A code example (though a boolean formula would suffice)

    Please Login or Register  to view this content.
    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".

  5. #5
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 365 on Win11 (365 on Win11 (desktop), 365 on Win11 (notebook)
    Posts
    8,207

    Re: IF A1 = Yes, then add 1 to B1

    Hi, AlvaroSiza,

    any time the cursor is placed in A1 the update would take place - let´s see if that´s what Jon is after.

    Ciao,
    Holger

  6. #6
    Registered User
    Join Date
    04-29-2013
    Location
    Maryland, USA
    MS-Off Ver
    Excel 2010
    Posts
    50

    Re: IF A1 = Yes, then add 1 to B1

    SixthSense and Holger, thank you for your assistance. But, now, I have been smoked out.

    I tried to keep the scenario simple, but it is rather complicated for me.

    Column A is updated by A1=X1

    Column X is the result of =IF(AX1>AO1,"YES","NO")

    So, the formula that is under your consideration should run on all cells in Column A, including the "NO" cells.

    I hope this answers your respective questions.

    Thanks, Jon

  7. #7
    Registered User
    Join Date
    04-29-2013
    Location
    Maryland, USA
    MS-Off Ver
    Excel 2010
    Posts
    50

    Re: IF A1 = Yes, then add 1 to B1

    Friends, I am a complete Excel knucklehead. I can only hope to learn this by the seat of my pants. What AlvaroSiza provided is absolutely, 100% over my head. Dim lngB As Long is some guy's name for all I know. Sorry.

  8. #8
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 365 on Win11 (365 on Win11 (desktop), 365 on Win11 (notebook)
    Posts
    8,207

    Re: IF A1 = Yes, then add 1 to B1

    Hi, Jon,

    what about the other two columns mentioned here: is data entered manually or a query? If entered manually we could use the Worksheet_Change-Event for these two columns to monitor any change and a possible update to Column B from there (leavoing Column A on it´s own). If it´s a formula there as well I´m lost as I would not know how to find a limitation to the update (I would think that any new calculation would trigger an event we need to augment the cells or set Calculation to manual and use that for an update).

    Ciao,
    Holger

  9. #9
    Registered User
    Join Date
    04-29-2013
    Location
    Maryland, USA
    MS-Off Ver
    Excel 2010
    Posts
    50

    Re: IF A1 = Yes, then add 1 to B1

    Holger,

    Column AX is entered manually (copy and paste).

    Column AO is VLookup formula from another page.

    Thanks.

  10. #10
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 365 on Win11 (365 on Win11 (desktop), 365 on Win11 (notebook)
    Posts
    8,207

    Re: IF A1 = Yes, then add 1 to B1

    Hi, Jon,

    I had hoped for a quick solution to your problem here but the Formulas in Column AO give me a hard time as they may deliver some other result when the data for the VLookUp is altered. If that data table isn´t altered we may rely solely on column AX and loop through all cells which are entered there in order to find out whether the criteria for an update in Column B is given or not.

    Ciao,
    Holger

  11. #11
    Registered User
    Join Date
    04-29-2013
    Location
    Maryland, USA
    MS-Off Ver
    Excel 2010
    Posts
    50

    Re: IF A1 = Yes, then add 1 to B1

    Holger, the data table is changed every day. Today's Column AX is tomorrow's VLookup data table. I am going to show you a formula that was worked out by WEAZEL from another forum. Some of the same columns are referenced in his formula. I was thinking I could dissect his formula and glean something for the column in question. Hang onto your seat.

    =IF(AND(AM2="Yes",AN2="Yes",Y2>=1,Y2<=20),Y2+1,IF(AND(AM2="Yes",AN2="Yes",Y2>=-10,Y2<=-1),1,IF(AND(AM2="Yes",AN2="No",Y2>=1,Y2<=20),-1,IF(AND(AM2="Yes",AN2="No",Y2>=-10,Y2<=-1), Y2+-1,IF(AND(AM2="No",AN2="No"),Y2,"")))))

  12. #12
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 365 on Win11 (365 on Win11 (desktop), 365 on Win11 (notebook)
    Posts
    8,207

    Re: IF A1 = Yes, then add 1 to B1

    Hi, Jon,

    would it be possible that you attach a sample workbook with some data and some formulas to have a look at?

    Ciao,
    Holger

  13. #13
    Registered User
    Join Date
    04-29-2013
    Location
    Maryland, USA
    MS-Off Ver
    Excel 2010
    Posts
    50

    Re: IF A1 = Yes, then add 1 to B1

    Hi, Holger.

    I have created a sample workbook that will show you exactly what I wish to do. Having difficulty uploading it. -Jon

  14. #14
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 365 on Win11 (365 on Win11 (desktop), 365 on Win11 (notebook)
    Posts
    8,207

    Re: IF A1 = Yes, then add 1 to B1

    Hi, Jon,

    maybe the description may help (if the workbook is not too big in size for the forum - I must admit I don´t know the limits for EF):
    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic
    If the workbook is too big maybe use some free uploading service (but that would only be the second choice).

    Ciao,
    Holger

  15. #15
    Registered User
    Join Date
    04-29-2013
    Location
    Maryland, USA
    MS-Off Ver
    Excel 2010
    Posts
    50

    Re: IF A1 = Yes, then add 1 to B1

    IF F2 = YES.zip I think this will work. It is compressed to work withing the size limits. Cheers!

    Holger, the size limits are shown in the Question Mark above the upload button.

    Thanks for taking a look. -Jon
    Last edited by ThanksAlot; 06-18-2013 at 02:55 PM.

  16. #16
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 365 on Win11 (365 on Win11 (desktop), 365 on Win11 (notebook)
    Posts
    8,207

    Re: IF A1 = Yes, then add 1 to B1

    Hi, Jon,

    as you noted in the sample there are 2 columns which are updated and deliver the foundation for any calculation we will take care of these and use them for an event to raise the values in other columns. Both Column L and M on Front page are monitored. Any manual change (including the pasting of new values) will trigger an event when macros are enabled. A check is fulfilled to see if the number of days has increased and if so the numbers in Column B and C according to the monitored columns as well as those to compare with will be augmented.

    Code goes behind Sheet Front page (right click on the worksheet tab, chosse ViewCode, paste the code into the code window):
    Please Login or Register  to view this content.
    Ciao,
    Holger
    Attached Files Attached Files

  17. #17
    Registered User
    Join Date
    04-29-2013
    Location
    Maryland, USA
    MS-Off Ver
    Excel 2010
    Posts
    50

    Re: IF A1 = Yes, then add 1 to B1

    Thanks, Holger. I will try your solution, and let you know how it works. It will take me a few days to get back to you, but I will. I have never worked with code like this, so I'll be stumped until I get the hang of it. Cheers! -Jon

+ 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