+ Reply to Thread
Results 1 to 3 of 3

Filter, copy specific columns, and paste to another sheet as VALUES ONLY

Hybrid View

  1. #1
    Registered User
    Join Date
    08-03-2010
    Location
    Buenos Aires
    MS-Off Ver
    Excel 2003
    Posts
    6

    Question Filter, copy specific columns, and paste to another sheet as VALUES ONLY

    Hi guys, I know this must be a repetitive subject to you, but I just can´t make this work despite all the posts I read, so here it goes, and I really appreciate your help.

    I took a code from this post: http://www.excelforum.com/excel-prog...ml#post2356294
    I find it really helpfull, but now I need to copy only the values... not the formulas.

    My code is as follows:

    Dim wsSource As Worksheet, wsOutput As Worksheet, rngData As Range
    Set wsSource = Sheets("1- Status")
    Set wsOutput = Sheets("HR")
    With wsSource
    Set rngData = .AutoFilter.Range
    If rngData.Columns(5).SpecialCells(xlCellTypeVisible).Count = 2 Then
    Intersect(rngData.Offset(1).Resize(rngData.Rows.Count - 1), .Range("A:A")).Copy wsOutput.Range("G6")
    Intersect(rngData.Offset(1).Resize(rngData.Rows.Count - 1), .Range("B:B")).Copy wsOutput.Range("I6")
    Intersect(rngData.Offset(1).Resize(rngData.Rows.Count - 1), .Range("H:H")).Copy wsOutput.Range("D8")
    Intersect(rngData.Offset(1).Resize(rngData.Rows.Count - 1), .Range("K:K")).Copy wsOutput.Range("D10")
    Intersect(rngData.Offset(1).Resize(rngData.Rows.Count - 1), .Range("X:X")).Copy wsOutput.Range("C40")
    Intersect(rngData.Offset(1).Resize(rngData.Rows.Count - 1), .Range("AF:AF")).Copy wsOutput.Range("B40")
    Else
    MsgBox "No hay datos para esa póliza, o existe más de 1 póliza con ese número"
    End If
    End With
    
    Set rngData = Nothing
    Set wsOutput = Nothing
    Set wsSource = Nothing

    As I told before, the code works fine. I just need it to copy the values.

    Thanks!
    Last edited by elobelix; 08-04-2010 at 12:00 PM.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Filter, copy specific columns, and paste to another sheet as VALUES ONLY

    Try this:
    Dim wsSource As Worksheet, wsOutput As Worksheet, rngData As Range
    Set wsSource = Sheets("1- Status")
    Set wsOutput = Sheets("HR")
    
    With wsSource
        Set rngData = .AutoFilter.Range
        If rngData.Columns(5).SpecialCells(xlCellTypeVisible).Count = 2 Then
            Intersect(rngData.Offset(1).Resize(rngData.Rows.Count - 1), .Range("A:A")).Copy
                wsOutput.Range("G6").PasteSpecial xlPasteValues
            Intersect(rngData.Offset(1).Resize(rngData.Rows.Count - 1), .Range("B:B")).Copy
                wsOutput.Range("I6").PasteSpecial xlPasteValues
            Intersect(rngData.Offset(1).Resize(rngData.Rows.Count - 1), .Range("H:H")).Copy
                wsOutput.Range("D8").PasteSpecial xlPasteValues
            Intersect(rngData.Offset(1).Resize(rngData.Rows.Count - 1), .Range("K:K")).Copy
                wsOutput.Range("D10").PasteSpecial xlPasteValues
            Intersect(rngData.Offset(1).Resize(rngData.Rows.Count - 1), .Range("X:X")).Copy
                wsOutput.Range("C40").PasteSpecial xlPasteValues
            Intersect(rngData.Offset(1).Resize(rngData.Rows.Count - 1), .Range("AF:AF")).Copy
                wsOutput.Range("B40").PasteSpecial xlPasteValues
        Else
            MsgBox "No hay datos para esa póliza, o existe más de 1 póliza con ese número"
        End If
    End With
    
    Set rngData = Nothing
    Set wsOutput = Nothing
    Set wsSource = Nothing
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    08-03-2010
    Location
    Buenos Aires
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Filter, copy specific columns, and paste to another sheet as VALUES ONLY

    Thanks a LOT.

    I tried that yesterday adding the ".PasteSpecial xlPasteValues" but somehow it didn´t work. Now it works beautifully.

    Thanks!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1