+ Reply to Thread
Results 1 to 3 of 3

VBA - If/Then scenario

  1. #1
    Registered User
    Join Date
    01-18-2013
    Location
    Funtown, USA
    MS-Off Ver
    Excel 2010
    Posts
    15

    VBA - If/Then scenario

    Hello, all.
    I'm working on code that will help my team with some of the reports they run. They run the report, which, due to some data integrity issues, pulls accounts that do not need to be worked. They will send an email out to a recipient, prompting them to clear the accounts from the queue.

    Here's the rundown (all info is arbitrary and made up)

    On the attached sheet, under column M, "File type", I need to see if any accounts are known as "Class B". If so, I need to email those files to another team to have the data corrected and keep them off of my report. There should already be a macro saved within this workbook (try Ctrl+Shift+G) that will accomplish this (when testing, you'll need to place your own email in the code), but I'll post the code below, just in case.

    If there are no "Class B" accounts on the report, then nothing needs to get fixed, however, the code I'm currently using will still send an email with a blank report. I'd like to avoid this.

    What I want, is to have the code to analyze and make a decision. If there are no Class B accounts, then don't send an email, and move on to the next section. If there are Class B accounts, then I need it to run the code that I already have, and send the email.

    I've dug around and have dabbled a bit with "if/then/else" stuff, but haven't found anything yet that I've been able to utilize to help me accomplish what I'm hoping for.
    Any help is greatly appreciated!

    VBATest - if_thens.xls

    Code:

    Please Login or Register  to view this content.

  2. #2
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: VBA - If/Then scenario

    You could try

    Please Login or Register  to view this content.
    This is equivalent to selecting A1 and then End -Down arrow. If this hits the bottom of the workbook, it means that no rows are given by the filter.

  3. #3
    Registered User
    Join Date
    01-18-2013
    Location
    Funtown, USA
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: VBA - If/Then scenario

    Thank you mrice!
    That seems to have done the trick.... and in implementing the code, I realized that I probably had the wrong approach in thinking I needed an Else or ElseIf, as that would have made things way too bulky.

    Simply adding the if scenario (although I did it with <>, instead of = to get it to work) looked at the one condition I needed to consider and then executed the remainder of the code.
    I'll post the code and mark this thread as SOLVED as soon as I finish full implementation and vetting.

    Thanks again.

+ 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. [SOLVED] Need help with a What If Scenario
    By icevinson in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-12-2013, 02:08 PM
  2. Scenario Manager displays same result for every scenario
    By terihoff in forum Excel - New Users/Basics
    Replies: 0
    Last Post: 11-10-2012, 07:14 PM
  3. Replies: 0
    Last Post: 08-16-2012, 01:32 PM
  4. IF, THEN scenario (I think) help, please... Thanks!
    By Micherie in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-10-2012, 05:45 PM
  5. Using What If scenario....
    By mdeegan in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-05-2011, 11:43 AM

Tags for this Thread

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