Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Using macros to cut & paste rows to a new worksheet

Hi all,

New to the forum here so be nice ;)

I'm after a little help here. What I want to acheive is this.

-For each row
if there are more than two occurences of the integer 2 in a se
range
{
then cut the entire row
paste the row at the first available position in worksheet B
}-

Basically I'm after a timesaver here as manuall cutting and pasting i
a real drag! I've not had much experience with macros & vb. I don'
mind getting my hands dirty with code though as I've coded in c/c++ fo
years.

Any help would be greatly appreciated

Cheers

Ric

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Using macros to cut & paste rows to a new worksheet

Hi
try (watch for linebreaks):

Sub paste_delete_rows()
Dim last_row As Long
Dim row_index As Long
Dim target_wks As Worksheet
Dim source_wks As Worksheet
Dim target_row As Long

Set source_wks = ActiveSheet
Set target_wks = Worksheets("sheet2")

Application.ScreenUpdating = False
last_row = source_wks.Cells(Rows.Count, "A").End(xlUp).Row
target_row = target_wks.Cells(Rows.Count, "A").End _
(xlUp).Row + 1
With source_wks
For row_index = last_row To 1 Step -1
If Application.CountIf(.Rows(row_index), 2) 1 Then
.Rows(row_index).Copy Destination:= _
target_wks.Rows(target_row)
target_row = target_row + 1
.Rows(row_index).Delete
End If
Next
End With
Application.ScreenUpdating = True
End Sub
-----Original Message-----
Hi all,

New to the forum here so be nice ;)

I'm after a little help here. What I want to acheive is

this.

-For each row
if there are more than two occurences of the integer 2 in

a set
range
{
then cut the entire row
paste the row at the first available position in

worksheet B
}-

Basically I'm after a timesaver here as manuall cutting

and pasting is
a real drag! I've not had much experience with macros &

vb. I don't
mind getting my hands dirty with code though as I've

coded in c/c++ for
years.

Any help would be greatly appreciated

Cheers

Rich


---
Message posted from http://www.ExcelForum.com/

.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
copy selected rows to second worksheet (NOT Cut + Paste) gyrra New Users to Excel 2 June 4th 10 09:05 PM
flexible paste rows function that inserts the right number of rows marika1981 Excel Discussion (Misc queries) 1 February 18th 05 02:40 AM
Macros to Cut and Paste David Excel Programming 1 June 6th 04 06:05 AM
Copy rows and paste to new worksheet Hammer_757 Excel Programming 2 May 6th 04 01:39 PM
lookup, cut, go to named worksheet and paste complete rows Terry T Excel Programming 1 February 24th 04 04:15 AM


All times are GMT +1. The time now is 07:18 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"