ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   New Users to Excel (https://www.excelbanter.com/new-users-excel/)
-   -   Copying selected rows to a new workbook (https://www.excelbanter.com/new-users-excel/270696-copying-selected-rows-new-workbook.html)

Jeffrey Marks

Copying selected rows to a new workbook
 
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


All times are GMT +1. The time now is 05:28 PM.

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