Macro help to copy specific rows to existing worksheet

mschiavo

New Member
Joined
Jun 27, 2011
Messages
2
Hello,

I'm in need of some help to write VBA code in Excel that does the following:

-For each row where the value in column A is a "1", copy the entire row to an existing worksheet (say named "result") in the same row number.

For example, I know how to conditionally copy rows and paste them into a worksheet beginning on row but, however, this request is to paste them in the same row number that they were copied from (e.g. if copied from row 5 on the original sheet, paste to row 5 on the result sheet)

Thanks!!!
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Try:
Code:
Sub MyMacro ()

Dim i a Long
Application.ScreenUpdating = False
For i = 1 to Range("A" & Rows.Count).End(xlUp).Row
  If Range("A" & i) = 1 Then 
     Rows(i).Copy
     Sheets("result").Range("A" & i).Pastespecial Paste:=xlPastevalues
  End If
Next i

Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,216,075
Messages
6,128,662
Members
449,462
Latest member
Chislobog

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