+ Reply to Thread
Results 1 to 9 of 9

Problem with output depending no If function

  1. #1
    Forum Contributor
    Join Date
    05-08-2009
    Location
    england
    MS-Off Ver
    Excel 2007
    Posts
    223

    Red face Problem with output depending no If function

    The following code is my attempt at trying to obtain an output depending on a couple of factors...which are fairly easy to see from the code below. However it is not working!!

    I'm sure for someone who knows what they are looking at it will be easy to resolve but I can't see the wood for the trees...

    What I'm looking for is as follows...

    Stream 1...

    If the value of CBLink = no

    then the output will be "A" if TBFurtherdets is empty, or
    "B" if it contains text.

    Stream 2...

    If the value of CBLink = yes

    then the output will be "B" if TBFurtherdets is empty, or
    "D" if it contains text.

    At the moment the code is running straight through and doubling up the output, which in my mind means I need to stop it somewhere when the desired response is identified, but I've tried moving things around etc. and I'm stumped.

    Also, apologies if the code is crap, i've cobbled this together...

    Please Login or Register  to view this content.

  2. #2
    Valued Forum Contributor tehneXus's Avatar
    Join Date
    04-12-2013
    Location
    Hamburg, Germany
    MS-Off Ver
    Work: MS-Office 2010 32bit @ Win8 32bit / Home: MS-Office 2016 32bit @ Win10 64bit
    Posts
    944

    Re: Problem with output depending no If function

    Hi

    I'd do this without the jumping to option1 and option2 (untested as no sample data provided):
    Please Login or Register  to view this content.
    If for some reason you WANT or HAVE TO stick to the jumping skip option2 at the end of option1:
    Please Login or Register  to view this content.
    Please check the if statements in:
    Please Login or Register  to view this content.
    as
    Please Login or Register  to view this content.
    makes no sense, TBFurtherdets MUST be <> vbNullstring in that line.

    Regards
    Please use [CODE]-TAGS
    When your problem is solved mark the thread SOLVED
    If an answer has helped you please click to give reputation
    Read the FORUM RULES

  3. #3
    Forum Contributor
    Join Date
    05-08-2009
    Location
    england
    MS-Off Ver
    Excel 2007
    Posts
    223

    Re: Problem with output depending no If function

    I see what should be happening but it still not working. The same is happening as was originally. That is why I thought it may be better to introduce the points to jump to.....................?

  4. #4
    Valued Forum Contributor tehneXus's Avatar
    Join Date
    04-12-2013
    Location
    Hamburg, Germany
    MS-Off Ver
    Work: MS-Office 2010 32bit @ Win8 32bit / Home: MS-Office 2016 32bit @ Win10 64bit
    Posts
    944

    Re: Problem with output depending no If function

    Hi,
    Please Login or Register  to view this content.
    could you provide example data?

    Regards

  5. #5
    Forum Contributor
    Join Date
    05-08-2009
    Location
    england
    MS-Off Ver
    Excel 2007
    Posts
    223

    Re: Problem with output depending no If function

    I have attached a mockup with the code for the commandbutton removed.
    Attached Files Attached Files

  6. #6
    Valued Forum Contributor tehneXus's Avatar
    Join Date
    04-12-2013
    Location
    Hamburg, Germany
    MS-Off Ver
    Work: MS-Office 2010 32bit @ Win8 32bit / Home: MS-Office 2016 32bit @ Win10 64bit
    Posts
    944

    Re: Problem with output depending no If function

    Hi,

    the following controls used in the code do not exist, at least do not have the name used:
    1. LBReport
    2. TBFurtherdets
    3. CBLink

    Variables not declared:
    1. strLinked

    Variables used to fill another variable, but are empty all code long:
    1. strLinked

    What do you want to do with:
    Please Login or Register  to view this content.
    ?

    Please make sure you uploaded the correct file.

    Regards

  7. #7
    Forum Contributor
    Join Date
    05-08-2009
    Location
    england
    MS-Off Ver
    Excel 2007
    Posts
    223

    Re: Problem with output depending no If function

    Hopefully this should be it with the code substituted.

    What I'm after is the equivalent of the result of clicking the commandbutton1 and the resulting data being dumpted into cell b2 for example.

    It is the method of causing one output rather than the other that I'm interested in.....
    Attached Files Attached Files

  8. #8
    Valued Forum Contributor tehneXus's Avatar
    Join Date
    04-12-2013
    Location
    Hamburg, Germany
    MS-Off Ver
    Work: MS-Office 2010 32bit @ Win8 32bit / Home: MS-Office 2016 32bit @ Win10 64bit
    Posts
    944

    Re: Problem with output depending no If function

    Hi,

    I found the following: The values which can be selected in the Combobox are "Yes" and "No" but you are checking for "yes" and "no". As the comparison is case sensitive both checks will result in FALSE, use this instead:
    Please Login or Register  to view this content.
    Another thing is writing the result into the worksheet, if you need help there just inform me.

    Regards

  9. #9
    Forum Contributor
    Join Date
    05-08-2009
    Location
    england
    MS-Off Ver
    Excel 2007
    Posts
    223

    Re: Problem with output depending no If function

    Its writing the result into the worksheet I am having trouble with. I'm aware of the case sensitivity bit.

+ 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