Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,814
Default Copy filtered data (Values only)

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!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,522
Default Copy filtered data (Values only)

Set Rng = ActiveSheet.AutoFilter.Range
Rng.Copy
Worksheets("Sheet2").Range("A1").PasteSpecial Paste:=xlPasteValues

Don Guillett
Microsoft MVP Excel
SalesAid Software

"Steve" wrote in message
...
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!


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Copy filtered data (Values only)

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!

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,814
Default Copy filtered data (Values only)

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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy Filtered Data [email protected] Excel Programming 4 March 26th 10 12:05 PM
Copy and pasting values of filtered rows Jammings Excel Discussion (Misc queries) 1 August 5th 09 06:45 PM
Return filtered values into report worksheet based on filtered valueon the data worksheet dicko1 Excel Worksheet Functions 1 April 21st 09 12:27 AM
paste data next to filtered values Freedom Excel Discussion (Misc queries) 1 April 6th 09 02:52 PM
Copy filtered data Secret Squirrel Excel Discussion (Misc queries) 3 March 28th 07 03:05 AM


All times are GMT +1. The time now is 03:45 AM.

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

About Us

"It's about Microsoft Excel"