Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default How do I cut instead of copy?

Hi

I am using some code to try and extract rows from one
spreadsheet based on the value in a particular column
matching that in another.

The code i have at the moment will copy the row but not
cut it also if there are 3 rows in my column matching the
criteria it wont copy all three it will just take one.

Do you know where the code is missing?

Mary
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default here is the code

Sorry this is the code I am using!!

Sub MoveMatches()

Dim wsSrc As Worksheet
Dim wsFind As Worksheet
Dim wsDest As Worksheet
Dim rCell As Range
Dim rFound As Range

Set wsSrc = Workbooks("1.xls").Sheets(1)
Set wsFind = Workbooks("2.xls").Sheets(1)
Set wsDest = Workbooks("2.xls").Sheets(2)

For Each rCell In wsSrc.Columns(1).Cells
Set rFound = wsFind.Columns(2).Find(rCell.Value)

If Not rFound Is Nothing Then
rCell.EntireRow.Cut wsDest.Range("A65536").End
(xlUp).Offset(1, 0)
End If

Next rCell

End Sub
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 110
Default here is the code

try this
rCell.EntireRow.Cut destination:=wsDest.Range("A65536").End
(xlUp).Offset(1, 0)

you introduce <destination:= after <cut i.e. cut(space)destination:=

I have not verified this . I have verified the following on the same
sheet(activesheet)

range("a1").EntireRow.Cut destination:=range("a10")


Mary wrote in message
...
Sorry this is the code I am using!!

Sub MoveMatches()

Dim wsSrc As Worksheet
Dim wsFind As Worksheet
Dim wsDest As Worksheet
Dim rCell As Range
Dim rFound As Range

Set wsSrc = Workbooks("1.xls").Sheets(1)
Set wsFind = Workbooks("2.xls").Sheets(1)
Set wsDest = Workbooks("2.xls").Sheets(2)

For Each rCell In wsSrc.Columns(1).Cells
Set rFound = wsFind.Columns(2).Find(rCell.Value)

If Not rFound Is Nothing Then
rCell.EntireRow.Cut wsDest.Range("A65536").End
(xlUp).Offset(1, 0)
End If

Next rCell

End Sub



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default here is the code

The end result seems as though I have spent a long time
going through each row with the egg timer showing.. and
then .. the row has been cut from 1.xls into 2.xls sheet2

I have another spreadsheet which I am using to hold the
button on to click and start off the procedure.

Could this be why there are problems?

Where should the code be in a module?

1.xls?
2.xls?
menu.xls?

Thanks again
-----Original Message-----
try this
rCell.EntireRow.Cut destination:=wsDest.Range

("A65536").End
(xlUp).Offset(1, 0)

you introduce <destination:= after <cut i.e. cut(space)

destination:=

I have not verified this . I have verified the

following on the same
sheet(activesheet)

range("a1").EntireRow.Cut destination:=range("a10")


Mary wrote in

message
...
Sorry this is the code I am using!!

Sub MoveMatches()

Dim wsSrc As Worksheet
Dim wsFind As Worksheet
Dim wsDest As Worksheet
Dim rCell As Range
Dim rFound As Range

Set wsSrc = Workbooks("1.xls").Sheets(1)
Set wsFind = Workbooks("2.xls").Sheets(1)
Set wsDest = Workbooks("2.xls").Sheets(2)

For Each rCell In wsSrc.Columns(1).Cells
Set rFound = wsFind.Columns(2).Find

(rCell.Value)

If Not rFound Is Nothing Then
rCell.EntireRow.Cut wsDest.Range("A65536").End
(xlUp).Offset(1, 0)
End If

Next rCell

End Sub



.

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 and paste versus copy and insert copied cells Alana New Users to Excel 1 September 28th 07 08:58 PM
Copy/Paste how to avoid the copy of formula cells w/o calc values Dennis Excel Discussion (Misc queries) 10 March 2nd 06 10:47 PM
EXCEL FILE a copy/a copy/a copy ....filename ve New Users to Excel 1 September 29th 05 09:12 PM
Code to copy range vs Copy Entire Worksheet - can't figure it out Mike Taylor Excel Programming 1 April 15th 04 08:34 PM
How copy format, font, color and border without copy/paste? Michel[_3_] Excel Programming 1 November 5th 03 04:43 PM


All times are GMT +1. The time now is 11:31 PM.

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

About Us

"It's about Microsoft Excel"