+ Reply to Thread
Results 1 to 3 of 3

Adding a new row to a list when filter is applied

Hybrid View

Macster Adding a new row to a list... 05-14-2009, 03:02 AM
antoka05 Re: Adding a new row to a... 05-14-2009, 03:39 AM
Macster Re: Adding a new row to a... 05-14-2009, 04:20 AM
  1. #1
    Registered User
    Join Date
    01-19-2009
    Location
    Stockholm
    MS-Off Ver
    Excel 2003
    Posts
    29

    Adding a new row to a list when filter is applied

    I'm stuck... I'm attaching a dummy worksheet.

    If filtering column C, just showing 'A's, by pressing the add row button, I want to copy the last cell in column C and pasting it in row 73, since it's the next unused cell when the worksheet is unfiltered.

    Can it be done?

    Thanks in advance
    Mac
    Attached Files Attached Files
    Last edited by Macster; 05-14-2009 at 04:20 AM.

  2. #2
    Forum Expert
    Join Date
    11-23-2005
    Location
    Rome
    MS-Off Ver
    Ms Office 2016
    Posts
    1,628

    Re: Adding a new row to a list when filter is applied

    Try with this macro:
    Sub Macro1()
       With ThisWorkbook.Sheets("sheet1")
          firstFreeRow = .Range("a1").CurrentRegion.Rows.Count + 1
       
          areasCount = .Range("c2:c" & firstFreeRow - 1).SpecialCells(xlCellTypeVisible). _
                       Areas.Count
       
          aAddress = Split(.Range("c2:c" & firstFreeRow - 1).SpecialCells(xlCellTypeVisible) _
                     .Areas(areasCount).Address(False, False), ":")
          
          lastFilteredRow = Range(aAddress(UBound(aAddress))).Row
          
          'to copy data you can write:
          .Cells(lastFilteredRow, "c").Copy .Cells(firstFreeRow, "c")
       End With
    End Sub
    Regards,
    Antonio

  3. #3
    Registered User
    Join Date
    01-19-2009
    Location
    Stockholm
    MS-Off Ver
    Excel 2003
    Posts
    29

    Re: Adding a new row to a list when filter is applied

    Excellent! Thank you!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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