+ Reply to Thread
Results 1 to 2 of 2

Copy rows, but exclude blank rows

Hybrid View

Guest Copy rows, but exclude blank... 11-01-2005, 02:05 AM
Guest RE: Copy rows, but exclude... 11-01-2005, 04:05 AM
  1. #1
    Mary
    Guest

    Copy rows, but exclude blank rows

    I have a worksheet with three columns that has over 1000 rows. What I want
    to do is copy a specific range to another workbook, but to exclude any rows
    that might be blank.

    Thanks
    Mary



  2. #2
    Patrick Molloy
    Guest

    RE: Copy rows, but exclude blank rows

    assuming no rows have blanks apart from those to delete then

    Option Explicit
    Sub test()
    CopyRows Selection, Sheet2.Range("B2")
    End Sub
    Sub CopyRows(source As Range, target As Range)
    With target.Resize(source.Rows.Count, source.Columns.Count)
    .Value = source.Value
    .SpecialCells(xlCellTypeBlanks).Delete
    End With
    End Sub

    sheet2 is an empty sheet
    select your range i=on sheet1 and run the code
    you can easily adapt the test procedure for specific ranges

    example
    CopyRows Sheet1.Range("MyData"), Sheet2.Range("B2")


    "Mary" wrote:

    > I have a worksheet with three columns that has over 1000 rows. What I want
    > to do is copy a specific range to another workbook, but to exclude any rows
    > that might be blank.
    >
    > Thanks
    > Mary
    >
    >
    >


+ 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