pedie
Well-known Member
- Joined
- Apr 28, 2010
- Messages
- 3,875
Hi, Need small help...VBA to start copying from x defined area...
from filtered result I want to copy from x row to last row from col A to K as shown below....this text way wont work...
For now i have my myindex as 4 which mean that i want to start copying from col. A lastrow - index [visible cells] to K last visible row...
from filtered result I want to copy from x row to last row from col A to K as shown below....this text way wont work...
For now i have my myindex as 4 which mean that i want to start copying from col. A lastrow - index [visible cells] to K last visible row...
Code:
[FONT=Courier New]Option Explicit[/FONT]
[FONT=Courier New]Sub Test1()[/FONT]
[FONT=Courier New]Dim datalr As Long[/FONT]
[FONT=Courier New]Dim myindex As Integer[/FONT]
[FONT=Courier New]myindex = 4[/FONT]
[FONT=Courier New]datalr = Sheet1.Range("A" & Rows.count).End(xlUp).Row[/FONT]
[FONT=Courier New]MsgBox datalr[/FONT]
[FONT=Courier New] With Sheet1[/FONT]
[FONT=Courier New] .AutoFilterMode = False[/FONT]
[FONT=Courier New] .Range("$A$1:$K$" & datalr).AutoFilter Field:=11, Criteria1:="2"[/FONT]
[FONT=Courier New] .Range("$A$1:$K$" & datalr).AutoFilter Field:=1, Criteria1:="EMP 3"[/FONT]
[FONT=Courier New] datalr = .Range("A" & Rows.count).End(xlUp).Row[/FONT]
[FONT=Courier New] MsgBox datalr[/FONT]
[FONT=Courier New] .Range("A" & datalr - myindex & ":K" & datalr).SpecialCells(xlCellTypeVisible).Copy[/FONT]
[FONT=Courier New] End With[/FONT]
[FONT=Courier New]End Sub[/FONT]