Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Copy And Paste Rows

Hi,

I have created this code which autofilters column a on
sheet 1 for the name which you input in the input box.
I then want it to copy all the rows on sheet1 that have
information in it a paste it onto sheet3 at the first
available row.

I have written the code below but when I run it. I get the
following message :-

Run-Time Error '1004'
The Command you chose cannot be performed with multiplt
selection. Select a single range & click the command
again.

Here's my code, please can someone tell me where I'm going
wrong.


Dim Name1 As String
Dim lastrow As Long
lastrow = Worksheets("Sheet1").Range("A65536").End
(xlUp).Row
Name1 = InputBox("Please Enter Name: ", "name1")
Worksheets("Sheet1").Range("A:B").AutoFilter Field:=1,
Criteria1:=Name1
Application.DisplayAlerts = False
Worksheets("Sheet1").Range("A1:B" &
lastrow).SpecialCells(xlCellTypeVisible).Cut
Worksheets("Sheet3").Range("A65536").End(2).Paste
Application.DisplayAlerts = True
Application.CutCopyMode = False
Worksheets("Sheet1").Range("A1").AutoFilter
End Sub

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Copy And Paste Rows

This worked for me:

Sub Tester1()
Dim Name1 As String
Dim lastrow As Long
lastrow = Worksheets("Sheet1").Range("A65536").End(xlUp).Row
Name1 = InputBox("Please Enter Name: ", "name1")
Worksheets("Sheet1").Range("A1").CurrentRegion. _
Resize(, 2).AutoFilter Field:=1, _
Criteria1:=Name1
Set rng = Worksheets("sheet1").AutoFilter.Range
Set rng = rng.Offset(1, 0).Resize(rng.Rows.Count - 1)
Application.DisplayAlerts = False
rng.Copy Destination:= _
Worksheets("Sheet3").Range("A65536").End(xlUp)(2)
rng.Delete
Application.DisplayAlerts = True
Application.CutCopyMode = False
Worksheets("Sheet1").Range("A1").AutoFilter
End Sub

--
Regards,
Tom Ogilvy



"Glenn Robertson" wrote in message
...
Hi,

I have created this code which autofilters column a on
sheet 1 for the name which you input in the input box.
I then want it to copy all the rows on sheet1 that have
information in it a paste it onto sheet3 at the first
available row.

I have written the code below but when I run it. I get the
following message :-

Run-Time Error '1004'
The Command you chose cannot be performed with multiplt
selection. Select a single range & click the command
again.

Here's my code, please can someone tell me where I'm going
wrong.


Dim Name1 As String
Dim lastrow As Long
lastrow = Worksheets("Sheet1").Range("A65536").End
(xlUp).Row
Name1 = InputBox("Please Enter Name: ", "name1")
Worksheets("Sheet1").Range("A:B").AutoFilter Field:=1,
Criteria1:=Name1
Application.DisplayAlerts = False
Worksheets("Sheet1").Range("A1:B" &
lastrow).SpecialCells(xlCellTypeVisible).Cut
Worksheets("Sheet3").Range("A65536").End(2).Paste
Application.DisplayAlerts = True
Application.CutCopyMode = False
Worksheets("Sheet1").Range("A1").AutoFilter
End Sub

Thanks



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
How do I Copy and Paste onto Same Rows after filtering out rows. TWT Excel Discussion (Misc queries) 2 October 20th 08 04:09 PM
How to Copy and Paste only new rows [email protected] Excel Worksheet Functions 2 April 9th 07 07:14 PM
Copy/Paste Rows JethroUK Excel Worksheet Functions 5 October 8th 06 12:19 PM
Hide Rows - copy and paste only rows that show Access101 Excel Worksheet Functions 3 March 1st 06 12:39 AM
How to Copy & Paste Rows? none Excel Discussion (Misc queries) 6 January 29th 05 02:37 PM


All times are GMT +1. The time now is 08:27 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"