Results 1 to 7 of 7

Thread: VBA code to move row to new spreadsheet

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Junior Member
    Join Date
    May 2013
    Posts
    21
    Rep Power
    0

    VBA code to move row to new spreadsheet

    I want to have this code wopy over all rows with a "Y" in column K to a new spreadsheet. I have this so far but it will only bring over the first row if it is marked. I need to get this to move over all rows marked even if the first row is not marked. Any help is appreciated. Thanks

    Code:
    Dim colLetter As String, SavePath As String
        Dim lastValue As String
        Dim wb As Workbook
        Dim lng As Long
        Dim currentRow As Long
        colLetter = "K"
        SavePath = ThisWorkbook.Path
            With ThisWorkbook.Worksheets(1)
            .Cells.AutoFilter field:=.Cells(1, colLetter).Column, Criteria1:="Y"
            lng = .Cells(.Rows.Count, colLetter).End(xlUp).Row
            Set wb = Application.Workbooks.Add(xlWorksheet)
            .Rows(1 & ":" & lng).Copy wb.Sheets(1).Cells(Rows.Count, 1).End(xlUp)
            .AutoFilterMode = False
    Last edited by Admin; 06-10-2013 at 10:52 PM. Reason: code tag added

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
  •