+ Reply to Thread
Results 1 to 3 of 3

For loop with mulitple if statements.

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    12-05-2008
    Location
    Kiruna
    Posts
    163

    For loop with mulitple if statements.

    Hi!

    Im trying to use a for loop with multiple if statement to add a the last date of multiple events to a textbox.

    1. The loop starts from the lastrow in the first column and test for a value.
    2. If it finds its value its test the second column for another value.
    3. If value is false it continues to test the first column for next of the same value (like 1.).
    4. If the value is true in the second column it adds the datevalue in the third column to TextBox1 in UserForm1.

    " Better description in the attached workbook" test.xlsm


    Sub test()
    Dim test As Worksheet
    
    Set test = ThisWorkbook.Sheets("test")
    
    lr = test.Cells(Rows.Count, 1).End(xlUp).Row
    
    
    
    For x = lr To 1 Step -1
    
    If test.Cells(x, 1) = 5 And test.Cells(x, 2) = "test" Then
    
    
    
    Next x
    
    
    End Sub
    Best regard

    Petter
    Last edited by Petter120; 09-03-2014 at 02:31 PM.

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

    Re: For loop with mulitple if statements.

    Sub test()
    Dim test As Worksheet
    
    Set test = ThisWorkbook.Sheets("test")
    
    lr = test.Cells(Rows.Count, 1).End(xlUp).Row
    
    For x = lr To 1 Step -1
    
    If test.Cells(x, 1) = 5 And test.Cells(x, 2) = "test" Then
        UserForm1.TextBox1.Text = test.Cells(x, 3).Value
        Exit Sub
    End If
    
    Next x
    
    End Sub

  3. #3
    Forum Contributor
    Join Date
    12-05-2008
    Location
    Kiruna
    Posts
    163

    Re: For loop with mulitple if statements.

    It works great, thank you verry much

+ 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. Mulitple If Statements...
    By MichaelDonnelly1984 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-17-2013, 01:25 PM
  2. Mulitple if statements and vlookups
    By tcrjmom in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 08-21-2013, 02:37 PM
  3. Mulitple IF statements
    By baldj003 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-11-2013, 10:41 AM
  4. mulitple IF statements
    By Back2Basics in forum Excel General
    Replies: 5
    Last Post: 12-04-2008, 04:33 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