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

Hi,

I needed help on the command below. I try to copy(based on the
selection criteria below) from tab A to tab "Staff" with with the
command below. However, the macro hang when I try to refresh it.
Please assist. Thank you.

Sub Macro1()
Selection.AutoFilter Field:=4, Criteria1:="=04*", Operator:=xlAnd
Dim lastrow As Long
lastrow = ActiveSheet.UsedRange.Rows.Count
For i = lastrow To 1


Rows("i").Select
Selection.Copy
Sheets("Staff").Select
ActiveSheet.Paste
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 220
Default Copy command

Jentan,

You need to put:

Next i

before End Sub.

--
Dan

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Copy command

See if this works. I did not test it. I assumed that one sheet is
named "A". If not change the code accordingly.

Sub Macro1()
Selection.AutoFilter Field:=4, Criteria1:="=04*", Operator:=xlAnd
Dim lastrow As Long
lastrow = Sheets("A").UsedRange.Rows.Count
x = 1
For i = lastrow To 1 Step -1
Sheets("A").Rows("i").Select
Selection.Copy
Sheets("Staff").Range("A" & x).Paste
x = x + 1
Next
End Sub



"Jentan" wrote:

Hi,

I needed help on the command below. I try to copy(based on the
selection criteria below) from tab A to tab "Staff" with with the
command below. However, the macro hang when I try to refresh it.
Please assist. Thank you.

Sub Macro1()
Selection.AutoFilter Field:=4, Criteria1:="=04*", Operator:=xlAnd
Dim lastrow As Long
lastrow = ActiveSheet.UsedRange.Rows.Count
For i = lastrow To 1


Rows("i").Select
Selection.Copy
Sheets("Staff").Select
ActiveSheet.Paste
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 Command will07 Excel Discussion (Misc queries) 1 July 4th 08 06:43 AM
Copy command browie Excel Programming 1 June 22nd 05 12:31 PM
Automate copy command? cwilliams Excel Worksheet Functions 0 April 5th 05 06:51 PM
I want to combine a "match" command with a copy and paste command. alomega Excel Programming 1 February 9th 05 05:52 PM
Copy down command button sowetoddid[_49_] Excel Programming 1 June 16th 04 03:48 PM


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