+ Reply to Thread
Results 1 to 5 of 5

Excel VBA nested if statements

  1. #1
    Registered User
    Join Date
    07-03-2015
    Location
    United States
    MS-Off Ver
    Office 2007
    Posts
    1

    Post Excel VBA nested if statements

    I am having trouble performing a certain action in excel 2007 using VBA. I have several columns containing stock information which I would like to separate by stock ticker. I may have anywhere from 2 to 8 rows of information relating to a single stock ticker. I would like to copy and paste these values to another part of the spreadsheet. For example I have the following VBA code which uses nested if then statements to compare cells in the AO column for the same stock ticker and copies the correct number of rows to CA4. When I try to use separate if then statements to compare AN3 to AN4 and copy one row if true, compare AN4 to AN5 and copy one row if true, etc. Once it compares two cells that don't match it still keeps copying them as if the result was true. I can only get it to work by checking from the bottom, starting with false comparisons and working my way up to end with true comparisons. Also I would like to be able to copy each stock ticker to a separate area, such as copying the rows for AAPL to CA4, and the rows for AIG to CA37 for example. Please see the attached excel file for reference. https://www.dropbox.com/s/wyhbizqfzb..._VBA.xlsx?dl=0


    Thank you so much for your help,

    Alex.

    Please Login or Register  to view this content.

  2. #2
    Forum Expert JasperD's Avatar
    Join Date
    05-07-2013
    Location
    Netherlands
    MS-Off Ver
    Excel 2016
    Posts
    1,393

    Re: Excel VBA nested if statements

    dropbox link doesn't work.

  3. #3
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,051

    Re: Excel VBA nested if statements

    Hi, welcome to the forum

    Please upload your file to the forum. many members are unable - or unwilling - to download files from file hosting sites.

    To attach a file to your post,
    click advanced (next to quick post),
    scroll down until you see "manage file",
    click that and select "add files" (top right corner).
    click "select files" find your file, click "open" click "upload" click 'done" bottom right. click "submit reply"

    Once the upload is completed the file name will appear below the input boxes in this window.
    You can then close the window to return to the new post screen.
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  4. #4
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    Win10/MSO2016
    Posts
    12,994

    Re: Excel VBA nested if statements

    Please Login or Register  to view this content.
    Ben Van Johnson

  5. #5
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,835

    Re: Excel VBA nested if statements

    Please Login or Register  to view this content.

+ 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] Excel Nested If statements
    By tyeinse2 in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 07-11-2014, 06:38 PM
  2. Nested IF / AND statements excel 2010
    By cossie2k in forum Excel General
    Replies: 2
    Last Post: 06-12-2012, 08:30 AM
  3. Nested IF statements with Text as IF and THEN (Excel 2007)
    By mrsbigglesworth in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-13-2010, 09:02 AM
  4. Replies: 12
    Last Post: 05-15-2009, 08:38 AM
  5. excel timesheet nested if statements
    By Liz in forum Excel General
    Replies: 1
    Last Post: 03-27-2006, 07:25 PM

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