Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default 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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy to filtered blank rows from another spreadsheet Juan Excel Discussion (Misc queries) 0 April 28th 10 07:59 PM
Copy several row headers to rows (blank) below for each header Rechie Excel Discussion (Misc queries) 1 October 26th 09 02:27 PM
copy from one sheet to another and skip the blank rows Dawn Excel Discussion (Misc queries) 3 March 11th 09 07:46 PM
Copy rows of data (eliminating blank rows) from fixed layout Sweepea Excel Discussion (Misc queries) 1 March 13th 07 11:05 PM
Sort Macro to Exclude Blank Rows? ScottPcola Excel Worksheet Functions 1 January 5th 06 07:10 PM


All times are GMT +1. The time now is 02:40 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"