Copy active lines to new worksheet

KimC2504

Board Regular
Joined
Jul 17, 2012
Messages
141
Hi, I am very rusty with my VBA and need to write some quick code so I am hoping someone can help me. I have a list of data with amounts in column F. If Column F is greater than zero, then I want to copy data from column B, C & F into worksheet 2. I got this to work however column F is a formula and it copies the formula and I need the value. When I tried to use .pasteSpecial xlPasteValues my code wouldn't work. Any suggestions??
Sub COPY_active_lines()
For MY_ROWS = 4 To 100
If Range("F" & MY_ROWS).Value > 0 Then
Range("B" & MY_ROWS & ":C" & MY_ROWS).Copy _
Sheets("Sheet2").Range("B" & Rows.Count).End(xlUp).Offset(1, 0)
End If

Next MY_ROWS

For MY_ROWS = 4 To 100
If Range("F" & MY_ROWS).Value > 0 Then
Range("f" & MY_ROWS).Copy _
Sheets("Sheet2").Range("d" & Rows.Count).End(xlUp).Offset(1, 0)
'.PasteSpecial xlPasteValues

End If

Next MY_ROWS


End Sub
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Try

Code:
Sub COPY_active_lines()
For MY_ROWS = 4 To 100
If Range("F" & MY_ROWS).Value > 0 Then
Range("B" & MY_ROWS & ":C" & MY_ROWS).Copy _
Sheets("Sheet2").Range("B" & Rows.Count).End(xlUp).Offset(1, 0)
End If

Next MY_ROWS

For MY_ROWS = 4 To 100
If Range("F" & MY_ROWS).Value > 0 Then
Range("f" & MY_ROWS).Copy
Sheets("Sheet2").Range("d" & Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial Paste:=xlPasteValues

End If

Next MY_ROWS


End Sub
 
Upvote 0

Forum statistics

Threads
1,214,904
Messages
6,122,169
Members
449,070
Latest member
webster33

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