View Full Version : Move rows if conditions meet
suriyahi
10-15-2008, 11:38 AM
Hi,
 
In Col. 'A', I have Issues ID and Col. 'K' has Status. If cells in Col. A are either '111' or '112', cut these row/s and paste them into row right above in where cell value in Col. 'K' is 'Proudct'. Cna you please help me with this? Thanks in advance? Let me know if you need to see sample copy.
Thanks again!
Simon Lloyd
10-15-2008, 11:44 AM
Is "Product" the title of column K?, its fairly simple to do, attach a workbook showing your structure and we can help you.
suriyahi
10-15-2008, 12:10 PM
Actually in Col. K, title is 'Status' and choices in that col. are 'Active' and 'Monitor'. Please see attached spreadsheet. Again...thank you..and let me know if you have any questions.:banghead:
georgiboy
10-15-2008, 12:29 PM
Could you post a spreadsheet with how you would like it to look?
Simon Lloyd
10-15-2008, 12:45 PM
This may come as a big surprise to you, but...........your workbook doesn't even have the word "product" in it!, would you like to try again at explaining what you want?
suriyahi
10-15-2008, 12:59 PM
Yes, I apologize. I miscommunicated. Here is the issue:
 
In Col. 'A', I have Issues ID and Col. 'K' has Status. If cells in Col. A are either '288'or '289', cut these entire row/s and paste them into row right above in where cell value in Col. 'K' is 'Monitor'. Thanks again! I have renames 'Before' tab and 'After' tab so that you can see how the 'After' tab will look like once you run the macro. Please let me know if this makes sense now. Thanks again!!
Bob Phillips
10-15-2008, 02:17 PM
Public Sub ProcessData()
    Dim i As Long
    Dim LastRow As Long
    Dim InsertRow As Long
     
    With Application
         
        .ScreenUpdating = False
        .Calculation = xlCalculationManual
    End With
     
    With ActiveSheet
         
        LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
        For i = LastRow To 2 Step -1
             
            If .Cells(i, "K").Value = "Monitor" Then
            
                InsertRow = i
            ElseIf .Cells(i, "A").Value = 288 Or .Cells(i, "A").Value = 289 Then
            
                .Rows(i).Cut
                .Rows(InsertRow).Insert
                InsertRow = InsertRow - 1
            End If
        Next i
         
    End With
     
     With Application
        .Calculation = xlCalculationAutomatic
        .ScreenUpdating = True
    End With
 
End Sub
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.