Results 1 to 4 of 4

Thread: Loop and Check For Values In Entire Column in Excel

  1. #1
    Junior Member
    Join Date
    May 2012
    Posts
    1
    Rep Power
    0

    Post Loop and Check For Values In Entire Column in Excel

    I need this to check every cell in these columns. Not just the cells in row 2. Any assistance would be greatly appreciated.


    Code:
    If Sheets("RSL").Range("M2") = Sheets("FailedSpots").Range("L2") Then
    
        If Sheets("RSL").Range("K2") > Sheets("FailedSpots").Range("M2") Then
        
            Sheets("RSL").Range("K2").Value = Sheets("FailedSpots").Range("M2").Value
            
        End If
        
    End If
    Last edited by Admin; 05-01-2012 at 10:15 PM. Reason: code tag added

  2. #2
    Administrator Admin's Avatar
    Join Date
    Mar 2011
    Posts
    1,123
    Rep Power
    10
    Hi Jeff5019

    Welcome to ExcelFox !!

    add code tags while posting codes
    Cheers !

    Excel Range to BBCode Table
    Use Social Networking Tools If You Like the Answers !

    Message to Cross Posters

    @ Home - Office 2010/2013/2016 on Win 10 (64 bit); @ Work - Office 2016 on Win 10 (64 bit)

  3. #3
    Administrator Admin's Avatar
    Join Date
    Mar 2011
    Posts
    1,123
    Rep Power
    10
    Hi

    try

    Code:
    Sub kTest()
    
        Dim LastRow     As Long, i As Long
        Dim RSL_Data, FS_Data, r As Range
        
        With Sheets("RSL")
            LastRow = .Range("m" & .Rows.Count).End(xlUp).Row
            Set r = .Range("k2:m" & LastRow)
            RSL_Data = r.Value2
        End With
        
        With Sheets("FailedSpots")
            LastRow = .Range("m" & .Rows.Count).End(xlUp).Row
            FS_Data = .Range("l2:m" & LastRow)
        End With
            
        
        For i = 1 To LastRow - 1
            If RSL_Data(i, 3) = FS_Data(i, 1) Then
                If RSL_Data(i, 1) > FS_Data(i, 2) Then
                    RSL_Data(i, 1) = FS_Data(i, 2)
                End If
            End If
        Next
        
        r = RSL_Data
    
    End Sub
    Cheers !

    Excel Range to BBCode Table
    Use Social Networking Tools If You Like the Answers !

    Message to Cross Posters

    @ Home - Office 2010/2013/2016 on Win 10 (64 bit); @ Work - Office 2016 on Win 10 (64 bit)

  4. #4
    Administrator Excel Fox's Avatar
    Join Date
    Mar 2011
    Posts
    1,402
    Rep Power
    10
    Added a more generic thread title. Jeff, for posterity and for the sake of people searching for similar queries in Excel, it would be best to provide a thread title that describes the objective in a more concise manner.
    A dream is not something you see when you are asleep, but something you strive for when you are awake.

    It's usually a bad idea to say that something can't be done.

    The difference between dream and aim, is that one requires soundless sleep to see and the other requires sleepless efforts to achieve

    Join us at Facebook

Similar Threads

  1. Delete Entire Row For All Empty Cells In Column
    By johnreid7477 in forum Excel Help
    Replies: 4
    Last Post: 06-15-2013, 05:50 AM
  2. Replies: 1
    Last Post: 06-12-2013, 07:42 PM
  3. Vlookup Multiple Values By Adding Formula With Loop In VBA
    By Safal Shrestha in forum Excel Help
    Replies: 15
    Last Post: 04-22-2013, 04:49 PM
  4. Loop to two columns and Concatenate values
    By ivandgreat in forum Excel Help
    Replies: 15
    Last Post: 04-14-2013, 08:20 PM
  5. Macro to check values based on certain text
    By Howardc in forum Excel Help
    Replies: 25
    Last Post: 11-05-2012, 09:03 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •