PC Review


Reply
Thread Tools Rate Thread

Copy filtered data (Values only)

 
 
Steve
Guest
Posts: n/a
 
      29th Apr 2010
The following code copies filtered data:

Set Rng = ActiveSheet.AutoFilter.Range
Rng.Copy Destination:=Worksheets("Sheet2").Range("A1")

but copies values and formulae. (e.g. .PasteSpecial xlPasteValues)

How do I modify to the copy only the values
Thanks!
 
Reply With Quote
 
 
 
 
Don Guillett
Guest
Posts: n/a
 
      29th Apr 2010
Set Rng = ActiveSheet.AutoFilter.Range
Rng.Copy
Worksheets("Sheet2").Range("A1").PasteSpecial Paste:=xlPasteValues

Don Guillett
Microsoft MVP Excel
SalesAid Software
(E-Mail Removed)
"Steve" <(E-Mail Removed)> wrote in message
news:5E54D33F-2DE0-48E4-8D27-(E-Mail Removed)...
> The following code copies filtered data:
>
> Set Rng = ActiveSheet.AutoFilter.Range
> Rng.Copy Destination:=Worksheets("Sheet2").Range("A1")
>
> but copies values and formulae. (e.g. .PasteSpecial xlPasteValues)
>
> How do I modify to the copy only the values
> Thanks!


 
Reply With Quote
 
Jacob Skaria
Guest
Posts: n/a
 
      29th Apr 2010
Try one of the below macros..

Sub Macro1()
Dim rng As Range
Set rng = ActiveSheet.AutoFilter.Range
rng.Copy
Worksheets("Sheet2").Range("A1").PasteSpecial (xlPasteValues)
Application.CutCopyMode = False
End Sub

Sub Macro2()
Dim rng As Range
Set rng = ActiveSheet.AutoFilter.Range
rng.Copy Destination:=Worksheets("Sheet2").Range("A1")
Worksheets("Sheet2").UsedRange = Worksheets("Sheet2").UsedRange.Value
End Sub

--
Jacob (MVP - Excel)


"Steve" wrote:

> The following code copies filtered data:
>
> Set Rng = ActiveSheet.AutoFilter.Range
> Rng.Copy Destination:=Worksheets("Sheet2").Range("A1")
>
> but copies values and formulae. (e.g. .PasteSpecial xlPasteValues)
>
> How do I modify to the copy only the values
> Thanks!

 
Reply With Quote
 
Steve
Guest
Posts: n/a
 
      29th Apr 2010
Thanks Jacob
That is working now. I was hoping this would fix another issue I am having
but it didn't. Once I copy to sheet2 I want to save that sheet as a csv.
The code creates an archive copy (with timestamp suffix) and also a working
copy (without time stamp) that is uploaded via FTP. This is the code that I
am using:

Dim strWksheet As String
Dim strPath As String
Dim strFileName As String
Dim strTimeStamp As String


strWksheet = "sheet2"
strPath = "mypath"
strFileName = "NewFile"
strTimeStamp = Format(Now(), "yyyy-mm-dd_hhmm")


Sheets(strWksheet).Copy
ActiveWorkbook.SaveAs Filename:=strPath & strFileName & _
strTimeStamp & ".xls", FileFormat:= _
xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False

'close the new worksheet
ActiveWindow.Close
Application.DisplayAlerts = False
Sheets(strWksheet).Copy
ActiveWorkbook.SaveAs Filename:=strPath & Left(strFileName, 10) _
& ".txt", FileFormat:=xlCSV, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
ActiveWindow.Close
Application.DisplayAlerts = True
'close the new worksheet

Application.ScreenUpdating = True


exit_Sub:
On Error Resume Next
Exit Sub

err_Sub:
Debug.Print "Error: " & Err.Number & " - (" & _
Err.Description & _
") - Sub: Copy_Data_Worksheet - " & Now()
GoTo exit_Sub
"Jacob Skaria" wrote:

> Try one of the below macros..
>
> Sub Macro1()
> Dim rng As Range
> Set rng = ActiveSheet.AutoFilter.Range
> rng.Copy
> Worksheets("Sheet2").Range("A1").PasteSpecial (xlPasteValues)
> Application.CutCopyMode = False
> End Sub
>
> Sub Macro2()
> Dim rng As Range
> Set rng = ActiveSheet.AutoFilter.Range
> rng.Copy Destination:=Worksheets("Sheet2").Range("A1")
> Worksheets("Sheet2").UsedRange = Worksheets("Sheet2").UsedRange.Value
> End Sub
>
> --
> Jacob (MVP - Excel)
>
>
> "Steve" wrote:
>
> > The following code copies filtered data:
> >
> > Set Rng = ActiveSheet.AutoFilter.Range
> > Rng.Copy Destination:=Worksheets("Sheet2").Range("A1")
> >
> > but copies values and formulae. (e.g. .PasteSpecial xlPasteValues)
> >
> > How do I modify to the copy only the values
> > Thanks!

 
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
Excel2007: copying filtered table values, how can I copy ONLY thefiltered values AC Microsoft Excel Discussion 2 27th Nov 2009 09:27 PM
Copy and pasting values of filtered rows Jammings Microsoft Excel Misc 1 5th Aug 2009 06:45 PM
Return filtered values into report worksheet based on filtered valueon the data worksheet dicko1 Microsoft Excel Worksheet Functions 1 21st Apr 2009 12:27 AM
paste data next to filtered values Freedom Microsoft Excel Misc 1 6th Apr 2009 02:52 PM
Assigning values once data filtered =?Utf-8?B?SmFrZXNtaXRoNTM=?= Microsoft Access 1 11th Sep 2005 12:18 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:28 AM.