Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Jentan,
You need to put: Next i before End Sub. -- Dan |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Copy Command | Excel Discussion (Misc queries) | |||
Copy command | Excel Programming | |||
Automate copy command? | Excel Worksheet Functions | |||
I want to combine a "match" command with a copy and paste command. | Excel Programming | |||
Copy down command button | Excel Programming |