+ Reply to Thread
Results 1 to 3 of 3

If statement inside a loop

  1. #1
    Valued Forum Contributor
    Join Date
    01-10-2011
    Location
    swindon, england
    MS-Off Ver
    Excel 2010
    Posts
    317

    If statement inside a loop

    Hi

    Does anyone know how to create an if statement which has two variables?

    I need to create an if statement which will go inside a loop that loops through a cell range which first checks if it is empty and if its not then i need to to say if the value in the cell on row 1 of the corresponding column = "12 months" and the value in the cell in column E of the corresponding row contains "Per Unit then place "12 month per unit" into the cell in sheet variable PPCWBSht in the 4th column.

    I had a go at the writing the code myself however i get an error saying "Subscript out of range" and it highlights the row i have coloured red in the code below.

    Please Login or Register  to view this content.
    Next cellDoes anyone know how to do this?

    Thanks

    Jeskit

  2. #2
    Valued Forum Contributor
    Join Date
    07-17-2005
    Location
    Abergavenny, Wales, UK
    MS-Off Ver
    XL2003, XL2007, XL2010, XL2013, XL2016
    Posts
    608

    Re: If statement inside a loop

    Hi

    Post an example of your data so we can see what you are trying to do.
    --
    Regards
    Roger Govier
    Microsoft Excel MVP

  3. #3
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: If statement inside a loop

    Looks like AutoFilter might be a better option or use SpecialCells
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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