SORT,COPY AND PASTE

verluc

Well-known Member
Joined
Mar 1, 2002
Messages
1,451
I want to do the following via VBA :
I have in sheet1,in column M sometimes the number "1" in the range M1:M1000
If there is a number "1" then copy and paste the cell from column K to sheet2
Any idea?
Many thanks
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().

Von Pookie

MrExcel MVP
Joined
Feb 17, 2002
Messages
13,686
Try:

<font face=Tahoma><SPAN style="color:#00007F">Sub</SPAN> CopyCells()
<SPAN style="color:#00007F">Dim</SPAN> cell <SPAN style="color:#00007F">As</SPAN> Range

<SPAN style="color:#00007F">For</SPAN> <SPAN style="color:#00007F">Each</SPAN> cell <SPAN style="color:#00007F">In</SPAN> [M1:M1000]
    <SPAN style="color:#00007F">If</SPAN> cell.Value = 1 <SPAN style="color:#00007F">Then</SPAN> cell.Offset(0, -2).Copy Destination:= _
        Sheets("Sheet2").[A65536].End(xlUp).Offset(1, 0)
<SPAN style="color:#00007F">Next</SPAN> cell

<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>
 

Forum statistics

Threads
1,148,055
Messages
5,744,544
Members
423,882
Latest member
Seeham

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
Top