copy rows to new page

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello all,
I have a spreadsheet with value's of OPEN and CLOSED in Column C.
How can I create a macro that will move the rows (Columns A thru F) with
OPEN in column C to the OPEN tab and the rows with CLOSED to the CLOSED tab?

Any assistance is appreciated. I'm familar with VBA in Access, but not very
familar with code in Excel.
 
Hi david,

Make sure to test and to adjust as needed ...

Sub Macro1()

Dim i As Integer
Dim LastRow As Integer

LastRow = Cells(Cells.Rows.Count, "C").End(xlUp).Row
For i = 1 To LastRow
Range("C" & i).Select
If ActiveCell.Value = "OPEN" Then
ActiveCell.EntireRow.Copy
Sheets("OPEN").Select
Range("A1").Select
If Range("A1").Value <> "" Then
ActiveCell.Offset(1, 0).Select
ActiveSheet.Paste
Else
ActiveSheet.Paste
End If
Range("C" & i).Select
Sheets("DATA").Select
Range("C" & i).Select
ElseIf ActiveCell.Value = "CLOSE" Then
ActiveCell.EntireRow.Copy
Sheets("CLOSE").Select
Range("A1").Select
If Range("A1").Value <> "" Then
ActiveCell.Offset(1, 0).Select
ActiveSheet.Paste
Else
ActiveSheet.Paste
End If
Range("C" & i).Select
Sheets("DATA").Select
Range("C" & i).Select
End If
Application.CutCopyMode = xlCut
Next i
End Sub

HTH
Cheers
Carim
 

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

Back
Top