ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Copy Row to worksheet based on criteria (https://www.excelbanter.com/excel-discussion-misc-queries/133341-copy-row-worksheet-based-criteria.html)

JoePineapples

Copy Row to worksheet based on criteria
 
I currently have a worksheet which is being used as a monitoring form. On this form there is a milestone which requires the subject to enter a completion date or a revised date for completion (3 columns in Total).

What I would like to be able to do is copy any row(s) that have a figure entered into revised date column into sheet 2 of the workbook.

That way I should have a worksheet (sheet 2) That would have a list that contained all the milestones with revised dates.

What I am looking for is any advice on the best way to go about this? I was thinking about using code to do this (possibly implemented by a command button). Although my knowlege of code is quite limited.

Many Thanks

JP

JoePineapples

With help from elsewhere I've got what I was looking for.

Code:

Sub CopySheet1toSheet2()
    Dim OutSH As Worksheet, i As Long
    Sheets("CorrectiveMeasures").Cells.ClearContents
    Set OutSH = Sheets("CorrectiveMeasures")
    i = 0
    ii = 7
    With Sheets("Milestones")
        For Each Ce In .Range("f9:f38" & .Cells(Rows.Count, 1).End(xlUp).Row)
            If Ce.Value 0 Then
                i = i + 1
                Range(Ce.Offset(0, -5), Ce.Offset(0, -3)).Copy _
                Destination:=OutSH.Cells(ii, 1)
                ii = ii + 1
            End If
        Next Ce
    End With
End Sub

It is activated with a command button. If a date(s) is(are) entered into the range F9:F38 and the command button is clicked then cells A-C of that row(s) are pasted onto sheet CorrectiveMeasures starting on row 7.


All times are GMT +1. The time now is 11:50 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com