+ Reply to Thread
Results 1 to 4 of 4

Combining For/Next and IF/ELSE

  1. #1
    Registered User
    Join Date
    02-05-2014
    Location
    Prague, Czech Republic
    MS-Off Ver
    Excel 2010, Excel 2016
    Posts
    72

    Combining For/Next and IF/ELSE

    Hi everybody,

    I would have some sort of elementary question regarding VBA coding. I'd like to create a code with looping For/Next function and integrete IF/ELSE function in every loop.

    Is something like that even possible?

    The code below isn't working, so I'm little suspicious

    Please Login or Register  to view this content.
    Thank you very much for a help!

  2. #2
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,811

    Re: Combining For/Next and IF/ELSE

    Saying that the "code below isn't working" does not tell us very much. Are you getting a compile error (you should be)? run-time error? code runs but does the wrong things? What debugging steps have you tried? Can you identify the statement that is causing the error (like from stepping through the code)?

    If you are unfamiliar with debugging tools, I will refer you to this: http://www.cpearson.com/excel/DebuggingVBA.aspx

    You should have a compiler error "block if without end if" or however VBA likes to phrase it. Block if help file: https://msdn.microsoft.com/en-us/lib.../gg251599.aspx
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  3. #3
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,613

    Re: Combining For/Next and IF/ELSE

    For sure you are at least missing
    Please Login or Register  to view this content.
    before
    Please Login or Register  to view this content.
    Besides that the code shall work.
    But ... provided swap_profile_first_column named range is where you expect.
    Because you check one by one 135 cells right to the first cell of swap_profile_first_column range.
    Best Regards,

    Kaper

  4. #4
    Registered User
    Join Date
    02-05-2014
    Location
    Prague, Czech Republic
    MS-Off Ver
    Excel 2010, Excel 2016
    Posts
    72

    Re: Combining For/Next and IF/ELSE

    Hi guys,

    thanks a lot for your responses! The break downs of macro were indeed caused by not including "END IF" into the code.

    I was coming back to VBA coding after a while and apparentely forgot some elementary things But thank you again for your quick responses. You saved me a lot of time!

+ 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. Combining 3 If's
    By saltytuna in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 07-08-2014, 08:57 AM
  2. combining TWO If's.....
    By GS7clw in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-21-2013, 01:20 PM
  3. [SOLVED] Combining vertical cells into one and between blank rows start combining again?
    By mike_m1 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 08-21-2012, 12:19 PM
  4. Help with Combining IFs
    By Bleuwhale in forum Excel General
    Replies: 3
    Last Post: 02-04-2012, 04:24 PM
  5. Combining
    By coffeecup in forum Excel General
    Replies: 5
    Last Post: 12-16-2011, 12:33 PM
  6. Combining IF with MAX
    By babydee0413 in forum Excel General
    Replies: 1
    Last Post: 02-19-2010, 06:16 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