PC Review


Reply
Thread Tools Rate Thread

Copy command

 
 
Jentan
Guest
Posts: n/a
 
      15th Aug 2007
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 With Quote
 
 
 
 
Dan R.
Guest
Posts: n/a
 
      15th Aug 2007
Jentan,

You need to put:

Next i

before End Sub.

--
Dan

 
Reply With Quote
 
=?Utf-8?B?SkxHV2hpeg==?=
Guest
Posts: n/a
 
      15th Aug 2007
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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Command prompt "COPY" command not working in brand new Windows Vis CMD COPY command not working in Vista Windows Vista File Management 7 5th Feb 2008 09:20 PM
Cannot copy NTUSER; can copy command span CDs =?Utf-8?B?cHdyaWNoY3JlZWs=?= Windows XP Security 3 11th Mar 2006 12:36 AM
I want to combine a "match" command with a copy and paste command. =?Utf-8?B?YWxvbWVnYQ==?= Microsoft Excel Programming 1 9th Feb 2005 05:52 PM
Cannot copy file with copy command Ben Microsoft Windows 2000 4 3rd Nov 2004 09:01 PM
How can I copy 2 and more files with copy command? M. Nadeem Windows XP Customization 1 5th Aug 2004 09:20 AM


Features
 

Advertising
 

Newsgroups
 


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