+ Reply to Thread
Results 1 to 8 of 8

How to insert more conditions in if-statement

  1. #1
    Registered User
    Join Date
    11-08-2012
    Location
    Copenhagen
    MS-Off Ver
    Excel 2007
    Posts
    56

    How to insert more conditions in if-statement

    Hi guys

    I am working on a search and replace macro. It's purpose is that within a region that varies only in row size, it's suppose to compare two
    values, A and B. A is only placed in one cell in the region, while B is a one column range in the region.

    If A <> B, A should replace all B's in the region.

    These regions are placed on top of each other in a long table. Please see the sample workbook, SampleDRW.xlsm

    The code I am using is this:
    Please Login or Register  to view this content.
    The problem is if the B value in the next region is the same as the one before but the A value change, my code don't pick up on it, because it only looks for changing B!
    How can I expand the code to also pick up on this problem?

    Any help is very appreciated.

    Br. and happy friday!

    Danny

  2. #2
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: How to insert more conditions in if-statement

    Hi Danny,
    try it
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    11-08-2012
    Location
    Copenhagen
    MS-Off Ver
    Excel 2007
    Posts
    56

    Re: How to insert more conditions in if-statement

    Thanks a whole bunch nilem. A small little detail, and forgive my ignorance; the individual boxes vary in length,
    but it appears that with the CurrentRegion command, the code makes all boxes equal in length. This means that it
    inserts a lot of redundant values after the individual tables end.

    Should I change parameters in the .resize command to adapt to each individual box?

    Br/Danny

  4. #4
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: How to insert more conditions in if-statement

    Hi Danny,
    try it
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    11-08-2012
    Location
    Copenhagen
    MS-Off Ver
    Excel 2007
    Posts
    56

    Re: How to insert more conditions in if-statement

    Thanks nilem

    The code gives me an 'subscript out of range' run-time error.
    But it looks exactly like the old one.

  6. #6
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: How to insert more conditions in if-statement

    Could you show an example of the file where the error occurs

  7. #7
    Registered User
    Join Date
    11-08-2012
    Location
    Copenhagen
    MS-Off Ver
    Excel 2007
    Posts
    56

    Re: How to insert more conditions in if-statement

    Sure thing, the error occurs in this Sample workbook..

    SampleDRW060314.xlsm

    I can't figure out the error..

    Br/Danny

  8. #8
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: How to insert more conditions in if-statement

    Sub ertert()
    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] IF Statement Using Several Conditions
    By DDM64 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 05-28-2013, 09:46 PM
  2. Using if statement with two conditions
    By fionn_ in forum Excel General
    Replies: 5
    Last Post: 07-03-2012, 09:43 AM
  3. if statement with conditions
    By maacmaac in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 05-09-2009, 08:38 PM
  4. if statement with two conditions
    By mkmed in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-03-2007, 09:49 PM
  5. Replies: 3
    Last Post: 06-26-2005, 10:05 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