A Microsoft Excel forum. ExcelBanter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » ExcelBanter forum » Excel Newsgroups » Excel Programming
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Copy filtered data to sheet 2



 
 
Thread Tools Display Modes
  #1  
Old July 13th 12, 08:14 PM posted to microsoft.public.excel.programming
Jim Lavery
external usenet poster
 
Posts: 21
Default Copy filtered data to sheet 2

The filter works & it goes to the available cell in sheet2 but doesn't paste
the filtered data.

Any ideas?


'Option Explicit
Function FilterAndCopy(rng As Range, Choice As String)

Dim FiltRng As Range
Worksheets("sheet2").Select
Dim a As Integer
a = 0
Do
a = a + 1
Loop Until ActiveCell.Offset(a, 0) = ""
ActiveCell.Offset(a, 0).Activate
ActiveCell = FiltRng


rng.AutoFilter Field:=5, Criteria1:=Choice
On Error Resume Next
Set FiltRng = rng.SpecialCells(xlCellTypeVisible).EntireRow
On Error GoTo 0


Worksheets("Sheet2").Select
FiltRng.Copy Worksheets("Sheet2").ActiveCell
Range("A1").Select
Set FiltRng = Nothing
End Function


Other code on the form button is
Private Sub UserForm_Click()
Option Explicit

Private Sub CommandButton1_Click()
Dim rng As Range

'Set Error Handling
On Error GoTo ws_exit:
Application.EnableEvents = False
'Set Range
Set rng = ActiveSheet.UsedRange
'Cancel if no value entered in textbox
If TextBox1.Value = "" Then GoTo ws_exit:
'Call function Filterandcopy
FilterAndCopy rng, TextBox1.Value
rng.AutoFilter
'Exit sub
ws_exit:
Set rng = Nothing
Application.EnableEvents = True
Unload Me
End Sub


Ads
  #2  
Old July 25th 12, 01:55 PM posted to microsoft.public.excel.programming
pascal baro
external usenet poster
 
Posts: 19
Default Copy filtered data to sheet 2

Hi,

This code below copies an autofiltered list to another sheet:
---
Set r = ws.Range("A1").CurrentRegion
With r
.AutoFilter 13, "NZzzM", xlAnd
Set rv = .Offset(1).SpecialCells(xlCellTypeVisible)
End With
rv.Copy ws2.Range("A1")
---
Pascal Baro
 




Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy Paste from Class Sheet to Filtered List on Combined Sheet [email protected] Excel Programming 6 September 16th 08 04:30 PM
How do you copy filtered data to a new sheet? Kerry B Excel Discussion (Misc queries) 3 July 31st 07 08:48 PM
Copy filtered data Secret Squirrel Excel Discussion (Misc queries) 3 March 28th 07 03:05 AM
How to copy just the filtered data? ljCharlie Excel Discussion (Misc queries) 3 February 16th 07 06:38 PM
Copy filtered data Hans Knudsen Excel Discussion (Misc queries) 3 November 25th 05 01:29 PM


All times are GMT +1. The time now is 09:40 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Copyright ©2004-2013 ExcelBanter.
The comments are property of their posters.