+ Reply to Thread
Results 1 to 12 of 12

Long IF statement

  1. #1
    Forum Contributor
    Join Date
    09-18-2008
    Location
    Scotland
    Posts
    156

    Long IF statement

    I have a validation that I use to select a month, this in turn defines what gets returned in a formula.

    Example:

    Please Login or Register  to view this content.

    This does work but as I want to do include every month its far from elegant, is there a better method?
    Cheers
    Last edited by guerillaexcel; 04-07-2011 at 04:38 AM. Reason: solved, thank you.

  2. #2
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Long IF statement

    PHP Code: 
    =IF(INDIRECT(G1 "!$B8")=0,indirect(G1 "!D8"),""



  3. #3
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,602

    Re: Long IF statement

    Here, try this:

    =IF(INDIRECT(G1&"!B8")=0, INDIRECT(G1&"!D8"), "")

  4. #4
    Forum Contributor
    Join Date
    09-18-2008
    Location
    Scotland
    Posts
    156

    Re: Long IF statement

    fantastic lads, great minds there!! 1 minute apart
    Can I ask what the formula actually does.

  5. #5
    Forum Contributor
    Join Date
    09-18-2008
    Location
    Scotland
    Posts
    156

    Re: Long IF statement

    Oh and is it possible to drag and copy this formula to rows below?

  6. #6
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Long IF statement

    Yes you can, but in that case you probably need:

    PHP Code: 
    =IF(INDIRECT($G$"!$B8")=0,indirect($G$"!$D8"),""

  7. #7
    Forum Contributor
    Join Date
    09-18-2008
    Location
    Scotland
    Posts
    156

    Re: Long IF statement

    Thanks snb, but this does not appear to work, "!$B8" doesn't change as I drag the cell to copy into the rows below, likewise with "!$D8". Any thoughts or am I doing something really stupid here?

  8. #8
    Registered User
    Join Date
    04-01-2011
    Location
    Manila, Philippines
    MS-Off Ver
    2019
    Posts
    53

    Re: Long IF statement

    I think snb is offline right now, maybe we could help if you upload a sample your excel file.
    Simply hit the star button to say THANK YOU.

  9. #9
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Long IF statement

    Maybe:

    =IF(INDIRECT($G$1 & "!$B" & ROW(A8))=0,INDIRECT($G$1 & "!$D" & ROW(A8)),"")

    Dom
    "May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."

    Use code tags when posting your VBA code: [code] Your code here [/code]

    Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.

  10. #10
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,602

    Re: Long IF statement

    try this:

    =IF(INDIRECT($G$1&"!$B"&ROWS($B$1:$B8))=0,INDIRECT($G$1&"!$D"&ROWS($B$1:$B8)),"")

    ROWS($B$1:$B8) is number 8
    If you pull it down you get 9,10 etc

    For changing first number you need to adjust it.

  11. #11
    Forum Contributor
    Join Date
    09-18-2008
    Location
    Scotland
    Posts
    156

    Re: Long IF statement

    sure, see attached.
    Thanks
    Attached Files Attached Files

  12. #12
    Forum Contributor
    Join Date
    09-18-2008
    Location
    Scotland
    Posts
    156

    Re: Long IF statement

    BOOM! thats done the trick zbor, thank you very much!
    And Domski, your solution works equally well, thank you thank you!

+ 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