copying specific rows to an existing sheet, based on user paramete

G

Guest

Hi everyone,

I have a master sheet ("Master Sheet") containing rows of data. Each row
has a specific date. I want the system to select a month (1-12) from a
drop-down list, and click continue. On click, I want the system to copy all
rows matching the month value selected by the user, to an existing worksheet
("sheet 5")

can anyone help me out on this?
 
G

Guest

I had the drop down cell in cell D4 (Row 2 column 4). I also have column A
searcdhed for the value matching the drop down value starting in row 20. the
code belows adds new rows to sheet5 after the rows that already exist.


Sub worksheet_change(ByVal Target As Range)

If Target.Row = 2 And Target.Column = 4 Then

Sheet5RowCount = _
Sheets("sheet5").Cells(Rows.Count, 1).End(xlUp).Row + 1

'find last row in column A
lastrow = Cells(Rows.Count, 1).End(xlUp).Row
Set ColARange = Range(Cells(20, 1), Cells(lastrow, 1))


For Each cell In ColARange


If cell = Target Then

cell.EntireRow.Copy _
Destination:=Sheets("sheet5").Cells(Sheet5rowCount, 1)

Sheet5rowCount = Sheet5rowCount + 1
End If

Next cell
End If

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top