+ Reply to Thread
Results 1 to 6 of 6

copy & paste last 10 visible values

Hybrid View

  1. #1
    Registered User
    Join Date
    09-22-2015
    Location
    India
    MS-Off Ver
    MS office 10
    Posts
    15

    copy & paste last 10 visible values

    hello friends

    I want to copy last 10 visible values of column A. i have below macro, can anyone help me.

    Sub Filter_Copy_Paste()
        ' filter coulmn "A"
        With Sheets("EOD")
        .Range("A1:B30000").AutoFilter field:=1, Criteria1:=Sheets("System").Range("C2").Value
        End With
        ' Copy only visible rows to another sheets on same workbook
        Dim src As Worksheet
        Dim tgt As Worksheet
        Dim filterRange As Range
        Dim copyRange As Range
        Dim lastRow As Long
    
        Set src = ThisWorkbook.Sheets("EOD")
        Set tgt = ThisWorkbook.Sheets("System")
        
        lastRow = src.Range("B" & src.Rows.Count).End(xlUp).Row
        
        Set filterRange = src.Range("B2:B" & lastRow)
        Set copyRange = src.Range("B2:B" & lastRow)
        copyRange.SpecialCells(xlCellTypeVisible).Copy tgt.Range("B7")
       
        Set filterRange = src.Range("F2:F" & lastRow)
        Set copyRange = src.Range("F2:F" & lastRow)
        copyRange.SpecialCells(xlCellTypeVisible).Copy tgt.Range("C7")
    End Sub
    Thanks in advance.
    Last edited by Meena_Sassati; 01-13-2016 at 09:24 AM.

  2. #2
    Registered User
    Join Date
    09-22-2015
    Location
    India
    MS-Off Ver
    MS office 10
    Posts
    15

    Re: copy & paste last 10 visible values

    i tried Lastrow - 9, but not working

  3. #3
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: copy & paste last 10 visible values

    This is probably not very helpful, but maybe:

    Sub Meena_Sassati()
    Dim x As Long, y As Long, z As Long
    z = 0
    x = Columns(1).SpecialCells(2).SpecialCells(12).SpecialCells(xlCellTypeLastCell).row
    For y = x - 1 To 2 Step -1
        Cells(y, 1).Select
        If Rows(y).Hidden = False Then z = z + 1
        z = z
        If z = 10 Then Exit For
    Next y
    Range(Cells(ActiveCell.row, 1), Cells(x, 1)).SpecialCells(12).Select
    End Sub

  4. #4
    Registered User
    Join Date
    09-22-2015
    Location
    India
    MS-Off Ver
    MS office 10
    Posts
    15

    Re: copy & paste last 10 visible values

    Not Working.....

  5. #5
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: copy & paste last 10 visible values

    Can you attach a sample file showing a page before the macro is run and a page showing the result that you want?

  6. #6
    Registered User
    Join Date
    09-22-2015
    Location
    India
    MS-Off Ver
    MS office 10
    Posts
    15

    Re: copy & paste last 10 visible values

    Hi John

    Happy New Year...!!

    Thanks for valuable time, the sample workbook is attached for your reference.


    Thanks
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Copy Visible cells and paste values only to visible target cells
    By wotadude in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-20-2024, 12:01 AM
  2. Copy & Paste visible cells only
    By klopatios in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 05-06-2013, 03:59 AM
  3. How to copy/paste only what is visible
    By nenadmail in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-08-2012, 02:49 PM
  4. Use visible rows from autofilter to build Pivot table. Or use visible rows to Copy/Paste
    By mwhitedesigns in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-08-2012, 10:34 AM
  5. Copy and paste visible to different sheet
    By cabinetguy in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-04-2011, 03:04 PM
  6. [SOLVED] copy and paste visible columns
    By ferde in forum Excel General
    Replies: 1
    Last Post: 12-08-2005, 04:55 AM
  7. Copy paste visible on same sheet
    By Jay in forum Excel General
    Replies: 1
    Last Post: 09-26-2005, 12:05 PM
  8. [SOLVED] Copy & Paste visible cells only
    By Scott in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-23-2005, 12:06 PM

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