Copying selected rows to a new workbook

J

Jeffrey Marks

I'm trying to look at all rows in a worksheet. If the value in column C has the word case in it, I want to copy it to a new workbook.

The macro does create a new workbook, but nothing gets copied over. I could use some help. Thanks!

Jeff

Sub JustcaseWorkbook()
'
' JustcaseWorkbook Macro

Dim i As Integer, shName As String
Dim rowData As Range, rowXAxis As Range
Dim chtTitle As Range
Workbooks.Add
Windows("LABELINVENTORY7-20-2011 (1).xls").Activate
'
shName = "Sheet1"
Set rowData = Sheets(shName).Range("a5:c5")
For i = 5 To 194

If Range("A" & i).Value Like "*case*" Then
ActiveSheet.Range(Cells(1, i), Cells(3, i)).Select
Selection.Copy
Windows("Book2").Activate
Range("A" & i).Select
ActiveSheet.Paste
Windows("LABELINVENTORY7-20-2011 (1).xls").Activate
End If
Next i
Windows("LABELINVENTORY7-20-2011 (1).xls").Activate
Sheets(shName).Activate
Range("a1").Activate
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