+ Reply to Thread
Results 1 to 16 of 16

Problems with If logic for months. If this month, then.

  1. #1
    Registered User
    Join Date
    10-06-2014
    Location
    Greenville, SC
    MS-Off Ver
    2010
    Posts
    27

    Unhappy Problems with If logic for months. If this month, then.

    Good Day.

    I've been running in circles with this one.

    What I wish to accomplish is simple, yet it's leaving me perplexed.

    If January, then the number I have in another cell, and Feb through December should be 0. Then as the months tick off, Jan through the month chosen will be assigned a cell, and any months forward would be 0. For instance, if July is chosen as the current month, then c13=y4 and so on up till July, Aug through December would be 0 or "".

    If you need a further explanation, I can try to explain further. I don't have any hair left on this simple problem!
    Last edited by dceremuga; 07-31-2017 at 11:52 AM.

  2. #2
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,370

    Re: Problems with If logic for months. If this month, then.

    Attach a sample workbook (not image).

    Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate.

    Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.

  3. #3
    Registered User
    Join Date
    10-06-2014
    Location
    Greenville, SC
    MS-Off Ver
    2010
    Posts
    27

    Re: Problems with If logic for months. If this month, then.

    Please see attached. I've highlighted where the month is chosen and to the right of that the numbers that should populate.
    Attached Files Attached Files

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2406 (Windows 11 23H2 64-bit)
    Posts
    81,569

    Re: Problems with If logic for months. If this month, then.

    For instance, if July is chosen as the current month, then Y1=x20, Y2=x21, Y3=x22, Y4=x23, Y5=X24, Y6=X25, Y7=X26, Aug through December would be 0 or "".
    There is nothing in those cells in column X. Where should Excel find the data?
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  5. #5
    Registered User
    Join Date
    10-06-2014
    Location
    Greenville, SC
    MS-Off Ver
    2010
    Posts
    27

    Re: Problems with If logic for months. If this month, then.

    Quote Originally Posted by AliGW View Post
    There is nothing in those cells in column X. Where should Excel find the data?
    I was using that as an example. Now that you have the worksheet to reference, the true value of January would be c13=y4 and so on... It'll make sense now. I should almost delete this post and start over since I now understand what is needed to get help.

  6. #6
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2406 (Windows 11 23H2 64-bit)
    Posts
    81,569

    Re: Problems with If logic for months. If this month, then.

    No - you must not start a new thread. Here's something to get you started (you need calculation set to automatic):

    =IF(ROWS(Y$4:Y4)<=MATCH($O$4,$X$4:$X$15,0),C13,"")

    Copy this down, then edit C13 for each month. You will find that the months populate as you change the selector in O4.

  7. #7
    Registered User
    Join Date
    10-06-2014
    Location
    Greenville, SC
    MS-Off Ver
    2010
    Posts
    27

    Re: Problems with If logic for months. If this month, then.

    Quote Originally Posted by AliGW View Post
    No - you must not start a new thread. Here's something to get you started (you need calculation set to automatic):

    =IF(ROWS(Y$4:Y4)<=MATCH($O$4,$X$4:$X$15,0),C13,"")

    Copy this down, then edit C13 for each month. You will find that the months populate as you change the selector in O4.
    This is not working. When I put this in C13 and the month chosen is say "July", it simply puts in a 0. If the month July is chosen, January, February, March, April, May, June and July should get their value, everything after should get "". Unless I'm doing something wrong here. I want this to auto populate the month chosen and all of the previous months. This sounds odd, but it has a purpose for what I'm doing.

  8. #8
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2406 (Windows 11 23H2 64-bit)
    Posts
    81,569

    Re: Problems with If logic for months. If this month, then.

    Attach the sheet where you have attempted to apply the formula. Yes, it does work - I have tested it.

    Did you edit the C13 reference in the 11 other formulae to match the correct month? have you switched on auto-calculation?

  9. #9
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2406 (Windows 11 23H2 64-bit)
    Posts
    81,569

    Re: Problems with If logic for months. If this month, then.

    Explain the formula in C13 - what is it supposed to be doing?

  10. #10
    Registered User
    Join Date
    10-06-2014
    Location
    Greenville, SC
    MS-Off Ver
    2010
    Posts
    27

    Re: Problems with If logic for months. If this month, then.

    Ok, I put your formula into C13 exactly as typed. =IF(ROWS(Y$4:Y4)<=MATCH($O$4,$X$4:$X$15,0),C13,""). Then in cell C21 I put the formula =IF(ROWS(Y$4:Y4)<=MATCH($O$4,$X$4:$X$15,0),C21,"")

    C13 should contain the value of Y4.

  11. #11
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2406 (Windows 11 23H2 64-bit)
    Posts
    81,569

    Re: Problems with If logic for months. If this month, then.

    Oh, OK - you said the yellow area. Forget it, then - I had the wrong end of the stick - sorry.

  12. #12
    Registered User
    Join Date
    10-06-2014
    Location
    Greenville, SC
    MS-Off Ver
    2010
    Posts
    27

    Re: Problems with If logic for months. If this month, then.

    Maybe this will help. I would put this formulate into C13, C21, c29, c37, H13, h21, h29, h37, m13, m21, m29, m37

    If O4=X4 then C13=Y4, every thing else is ""
    If O4=X5 then C21=Y5 and C13=Y4, otherwise ""
    If O4=X6 then C29=Y6 and C21=y5 and C13=Y4, otherwise ""

    and so on.

  13. #13
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2406 (Windows 11 23H2 64-bit)
    Posts
    81,569

    Re: Problems with If logic for months. If this month, then.

    Not really, unless you want long IF formulae. What would be better would to be change the cells where the months are referenced to custom date format, then you can use the month number to decide whether or not the cell should be populated.

  14. #14
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2406 (Windows 11 23H2 64-bit)
    Posts
    81,569

    Re: Problems with If logic for months. If this month, then.

    Have a look at the attached. I've changed the formatting of the cells referencing months and then used this formula:

    =IF(MONTH($O$4)>=MONTH(A12),Y4,0)
    Attached Files Attached Files

  15. #15
    Registered User
    Join Date
    10-06-2014
    Location
    Greenville, SC
    MS-Off Ver
    2010
    Posts
    27

    Re: Problems with If logic for months. If this month, then.

    You are a genius. It works! Exactly what I was looking for. I had started to do LONG if statements. I see how you changed the date format. Nicely done sir.

    Answered.

  16. #16
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2406 (Windows 11 23H2 64-bit)
    Posts
    81,569

    Re: Problems with If logic for months. If this month, then.

    Not a sir - I hope I look female.

    You are welcome. If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Count how many dates are this month, 2 months and 3 months old
    By jimmisavage in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 06-21-2017, 09:21 AM
  2. Best logic to return TRUE in VBA if month NAMES are 1 apart?
    By dmasters4919 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-20-2015, 10:47 AM
  3. [SOLVED] VBA Insert Current Month, Year and subsequent months/year for 15 months
    By MichiganWilliams in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-19-2014, 03:49 PM
  4. [SOLVED] Logic Problems
    By ravin13524666 in forum Excel General
    Replies: 6
    Last Post: 05-31-2013, 07:36 AM
  5. Macro using vlookups comparing 2 months paysheet(previous month and current month)
    By srinivasan1965 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-07-2012, 03:45 AM
  6. Replies: 1
    Last Post: 11-22-2011, 08:11 AM
  7. And(month,year) logic
    By dstan15 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-01-2007, 11:20 AM

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