+ Reply to Thread
Results 1 to 18 of 18

If Statement with Multiple And , help please

  1. #1
    Forum Contributor
    Join Date
    01-03-2013
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    211

    If Statement with Multiple And , help please

    hi Everyone

    I get Error message "ApplicationDefined or Object Defined Error" when trying to run this code, any idea where the error is please ? I vaguely think it is the Multiple And...

    Thank you

    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: If Statement with Multiple And , help please

    When I run the code, I did not get an error.

  3. #3
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: If Statement with Multiple And , help please

    Remove the And if these lines as it has not any value

    Please Login or Register  to view this content.

  4. #4
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: If Statement with Multiple And , help please

    The primary thing that is messing you up is Cells(i, -4).Value. In your situation, there is no -4 column. It doesn't exist. Why don't you let us know what cell references you are actually wanting to use so we can rewrite the code for you. A sample workbook would make things easier.

  5. #5
    Forum Contributor
    Join Date
    01-03-2013
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    211

    Re: If Statement with Multiple And , help please

    Quote Originally Posted by AB33 View Post
    When I run the code, I did not get an error.
    you right it works now, Strange ?! Thanks for checking

  6. #6
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: If Statement with Multiple And , help please

    stnkynts is right.
    The code probably did not error because is it is returning the first condition, but if it goes to else if, it will fail.
    You can not go from column A to left, only right wing part is allowed to the right from column A.

  7. #7
    Forum Contributor
    Join Date
    01-03-2013
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    211

    Re: If Statement with Multiple And , help please

    Quote Originally Posted by AB33 View Post
    Remove the And if these lines as it has not any value

    Please Login or Register  to view this content.
    you right no need for And

  8. #8
    Forum Contributor
    Join Date
    01-03-2013
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    211

    Re: If Statement with Multiple And , help please

    Quote Originally Posted by bimo View Post
    you right it works now, Strange ?! Thanks for checking
    didn't get an error but the code does not what it is supposed to

  9. #9
    Forum Contributor
    Join Date
    01-03-2013
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    211

    Re: If Statement with Multiple And , help please

    Quote Originally Posted by stnkynts View Post
    The primary thing that is messing you up is Cells(i, -4).Value. In your situation, there is no -4 column. It doesn't exist. Why don't you let us know what cell references you are actually wanting to use so we can rewrite the code for you. A sample workbook would make things easier.
    here is the whole Code with a sample workbook I managed to get rid of error message related to trying to look for cells outside the work sheet but the code does not what it supposed to,

    the conditions are on column C and I and value to transpose are on column M

    Can you please see where the arguments falls and whether I could have smaller code ? not sure if VBA allow for two variables/dimensional arguments and if so how..

    Thank you
    Please Login or Register  to view this content.
    Attached Files Attached Files

  10. #10
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: If Statement with Multiple And , help please

    "the conditions are on column C and I and value to transpose are on column M "
    Need more and detailed explanation
    You have duplicates in column C and I
    What is the expected result? what values/column/rows do you want to transpose to column M?

  11. #11
    Forum Contributor
    Join Date
    01-03-2013
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    211

    Re: If Statement with Multiple And , help please

    Quote Originally Posted by AB33 View Post
    "the conditions are on column C and I and value to transpose are on column M "
    Need more and detailed explanation You have duplicates in column C and I
    What is the expected result? what values/column/rows do you want to transpose to column M?
    6 conditions mean that if values are repeated 6 times in column 6 And "discount" are repeated 6 times in Column I Then values in Column M ( down to the last repeated items) need to be transposed into Row i staring from column M

    Attached is the results sought

    Thanks,

  12. #12
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: If Statement with Multiple And , help please

    Unless I am missing an important piece of information, this should work for you:

    Please Login or Register  to view this content.

  13. #13
    Forum Contributor
    Join Date
    01-03-2013
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    211

    Re: If Statement with Multiple And , help please

    Quote Originally Posted by stnkynts View Post
    Unless I am missing an important piece of information, this should work for you:

    Please Login or Register  to view this content.
    genius!! Thank you!

  14. #14
    Forum Contributor
    Join Date
    01-03-2013
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    211

    Re: If Statement with Multiple And , help please

    Quote Originally Posted by stnkynts View Post
    Unless I am missing an important piece of information, this should work for you:

    Please Login or Register  to view this content.
    just a question please , do you think these instructions can handle large data ? 52K lines

  15. #15
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: If Statement with Multiple And , help please

    Yeah but it will take it a little bit. There are a couple of more efficient ways of doing it but I don't have the time at the moment to work something up. Try it on the 52k lines and see how long it takes and report back.

  16. #16
    Forum Contributor
    Join Date
    01-03-2013
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    211

    Re: If Statement with Multiple And , help please

    Quote Originally Posted by stnkynts View Post
    Yeah but it will take it a little bit. There are a couple of more efficient ways of doing it but I don't have the time at the moment to work something up. Try it on the 52k lines and see how long it takes and report back.
    there is actually an issue, when there is one value in I Column, it Copies all the blank cells bellows and try to paste them
    Last edited by bimo; 11-29-2014 at 06:58 AM.

  17. #17
    Forum Contributor
    Join Date
    01-03-2013
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    211

    Re: If Statement with Multiple And , help please

    Quote Originally Posted by bimo View Post
    there is actually an issue, when there is one value in I Column, it Copies all the blank cells bellows and try to paste them
    I have now modified the code, to deal with one and two repetition, and also I needed it to start pasting on one row higher.. it takes about 15min for the Macro to complete Thanks again for your help
    Please Login or Register  to view this content.

  18. #18
    Forum Contributor
    Join Date
    01-03-2013
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    211

    Re: If Statement with Multiple And , help please

    Quote Originally Posted by stnkynts View Post
    Yeah but it will take it a little bit. There are a couple of more efficient ways of doing it but I don't have the time at the moment to work something up. Try it on the 52k lines and see how long it takes and report back.
    had to modify the code, got confused when it is only one and two filled cells tried to copy and paste too many ..

    it takes about 15 min to do it.

    thanks again for your help

    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. Replies: 7
    Last Post: 08-11-2014, 12:05 PM
  2. [SOLVED] If statement that will look among multiple criteria and generate a statement
    By liz5818 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 07-01-2013, 04:12 PM
  3. multiple if statement
    By Blake 7 in forum Excel General
    Replies: 2
    Last Post: 09-14-2011, 08:50 AM
  4. IF statement using multiple variables to give multiple outcomes
    By stujordan in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-06-2009, 06:46 AM
  5. Help with a multiple OR statement.
    By Pank in forum Excel General
    Replies: 2
    Last Post: 07-11-2006, 01:35 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