Hello,
I have a spreadsheet I am trying to use a VBA to copy all rows that are "TRUE" in column A to a new spreadsheet. I wrote the below VBA. However, it is only pulling across the first instance of true. I need help getting this equation to work for every instance of true and not only the first.
Additionally, if you can help me with adding a part to change copy to cut and then delete the blank column I would appreciate it.
Sub cond_copy()
Dim data As Worksheet
Dim archive As Workbook
Set data = Sheet1
rng = data.Range("B1").Value
data.Activate
Finalrow = Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To Finalrow
If Cells(i, 1) = rng Then
Range(Cells(i, 1), Cells(i, 15)).Copy
Workbooks.Open ("L:\Distribution\ShippingOnly\Freight Bills\FedEx Tracking\Archive.xlsx")
Range("a1:A100").End(xlUp).Offset(2, 0).PasteSpecial xlPasteValuesAndNumberFormats
End If
Next i
End Sub
Thank you,
I have a spreadsheet I am trying to use a VBA to copy all rows that are "TRUE" in column A to a new spreadsheet. I wrote the below VBA. However, it is only pulling across the first instance of true. I need help getting this equation to work for every instance of true and not only the first.
Additionally, if you can help me with adding a part to change copy to cut and then delete the blank column I would appreciate it.
Sub cond_copy()
Dim data As Worksheet
Dim archive As Workbook
Set data = Sheet1
rng = data.Range("B1").Value
data.Activate
Finalrow = Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To Finalrow
If Cells(i, 1) = rng Then
Range(Cells(i, 1), Cells(i, 15)).Copy
Workbooks.Open ("L:\Distribution\ShippingOnly\Freight Bills\FedEx Tracking\Archive.xlsx")
Range("a1:A100").End(xlUp).Offset(2, 0).PasteSpecial xlPasteValuesAndNumberFormats
End If
Next i
End Sub
Thank you,