CSV Export with Column Criteria

bmorse

New Member
Joined
Jul 13, 2010
Messages
10
Hello!
I have a new project where I need to export data again. My data spans columns A - J, where if J = 101 (which is a calculated field and formatted as general), then copy all 101 rows to the desired sheet. Can you tell me how to do that? My current syntax is below and I get Object Required when trying to run it. Thank you for your help!

Sub GBEquipAllocation()


Dim cell As Range
Dim lastRow As Long, i As Long


lastRow = Range("J" & Rows.Count).End(xlUp).Row
i = 2 ' change this to the wanted starting row in sheet2


For Each cell In Sheets("Allocation").Range("J2:J" & lastRow)
If cell.Value.Range("J:J") = 101 Then
cell.EntireRow.Copy
GBEquipAlloc.Cells(i, 1).PasteSpecial xlPasteValues
i = i + 1
End If
Next


End Sub
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Have you tried it without the part highlighted:

Rich (BB code):
Sub GBEquipAllocation()


 Dim cell As Range
 Dim lastRow As Long, i As Long


 lastRow = Range("J" & Rows.Count).End(xlUp).Row
 i = 2 ' change this to the wanted starting row in sheet2


 For Each cell In Sheets("Allocation").Range("J2:J" & lastRow)
 If cell.Value.Range("J:J") = 101 Then
 cell.EntireRow.Copy
 GBEquipAlloc.Cells(i, 1).PasteSpecial xlPasteValues
 i = i + 1
 End If
 Next


 End Sub
 
Upvote 0
Then you would also need to reference it like:

Sheets("GBEquipAlloc").Cells(i, 1).PasteSpecial xlPasteValues
 
Upvote 0

Forum statistics

Threads
1,215,063
Messages
6,122,935
Members
449,094
Latest member
teemeren

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