VBA to archive data if it is true help

aegan1989

New Member
Joined
Aug 6, 2019
Messages
1
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,
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).

Forum statistics

Threads
1,214,385
Messages
6,119,208
Members
448,874
Latest member
b1step2far

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top