Results 1 to 7 of 7

Thread: VBA code to move row to new spreadsheet

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Junior Member
    Join Date
    May 2013
    Posts
    21
    Rep Power
    0
    This works great except it does not bring over to column headers. Can you help with that? I have almost destroyed the macro. Thanks

  2. #2
    Forum Guru Rick Rothstein's Avatar
    Join Date
    Feb 2012
    Posts
    662
    Rep Power
    15
    Quote Originally Posted by cdurfey View Post
    This works great except it does not bring over to column headers. Can you help with that? I have almost destroyed the macro. Thanks
    Not sure what you mean by "I have almost destroyed the macro", but this modified version of what I posted earlier should do what I think you want...
    Code:
    Dim ColLetter As String, SavePath As String
    Dim VisibleRows As Range, WS As Worksheet, wbOld As Workbook, wbNew As Workbook
    ColLetter = "K"
    Set wbOld = ThisWorkbook
    Set wbNew = Application.Workbooks.Add(xlWorksheet)
    Set WS = wbOld.Worksheets(1)
    WS.Cells.AutoFilter field:=WS.Cells(1, ColLetter).Column, Criteria1:="Y"
    WS.AutoFilter.Range.SpecialCells(xlVisible).Copy wbNew.Worksheets(1).Range("A1")
    WS.AutoFilterMode = False

  3. #3
    Junior Member
    Join Date
    May 2013
    Posts
    21
    Rep Power
    0
    That works perfect. Thanks

Similar Threads

  1. Replies: 4
    Last Post: 07-02-2013, 11:32 AM
  2. Excel VBA Code to Add New Sheets
    By cdurfey in forum Excel Help
    Replies: 1
    Last Post: 06-25-2013, 08:05 AM
  3. Replies: 7
    Last Post: 05-17-2013, 10:38 PM
  4. Replies: 1
    Last Post: 02-14-2013, 12:09 PM
  5. Vba Code to find value and paste on certain row
    By jwitte in forum Excel Help
    Replies: 3
    Last Post: 11-28-2012, 08:52 PM

Posting Permissions

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