Consulting

Results 1 to 7 of 7

Thread: Move rows if conditions meet

  1. #1
    VBAX Regular
    Joined
    Sep 2008
    Posts
    29
    Location

    Move rows if conditions meet

    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!

  2. #2
    Moderator VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,003
    Location
    Is "Product" the title of column K?, its fairly simple to do, attach a workbook showing your structure and we can help you.
    Regards,
    Simon
    Please read this before cross posting!
    In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
    If I have seen further it is by standing on the shoulders of giants.
    Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

  3. #3
    VBAX Regular
    Joined
    Sep 2008
    Posts
    29
    Location
    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.

  4. #4
    Moderator VBAX Master georgiboy's Avatar
    Joined
    Mar 2008
    Location
    Kent, England
    Posts
    1,198
    Location
    Could you post a spreadsheet with how you would like it to look?
    Click here for a guide on how to add code tags
    Click here for a guide on how to mark a thread as solved
    Click here for a guide on how to upload a file with your post

    Excel 365, Version 2403, Build 17425.20146

  5. #5
    Moderator VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,003
    Location
    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?
    Regards,
    Simon
    Please read this before cross posting!
    In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
    If I have seen further it is by standing on the shoulders of giants.
    Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

  6. #6
    VBAX Regular
    Joined
    Sep 2008
    Posts
    29
    Location

    Miscommunication

    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!!

  7. #7
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]


    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
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

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