Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Max Max is offline
external usenet poster
 
Posts: 9,221
Default Sub to copy only result lines within formula range, omit null string lines

Within say, E2:F20 are formulas returning results that are always neatly
bunched at the top. Blank: "" lines (null strings) if any, would appear
below result lines within E2:F20.

What I would like to do is for a sub to copy only the result lines within
E2:F20 (omit the null string lines), then paste special as values into an
adjacent 2 col range ie into G2:Hn*, & sort the pasted range by col G,
ascending.
*n may vary from 2 to 20

And if there are zero result lines, ie E2:F20 contains only null strings,
then "No results to sort" will be written in G2. Thanks for insights.
--
Max
Singapore
http://savefile.com/projects/236895
xdemechanik
---


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Sub to copy only result lines within formula range, omit null stri

Sub Doit()
Dim i As Long
Dim r As Range
Range("E2:F20").Copy
Range("G2").PasteSpecial xlValues
For i = 20 To 2 Step -1
Set r = Cells(i, "G")
If Trim(r.Text) = "" Then r.ClearContents
If Trim(r.Offset(0, 1).Text) = "" Then _
r.Offset(0, 1).ClearContents
Next
Range("G2:H20").Sort Key1:=Range("G2"), _
Order1:=xlAscending, Header:=xlNo
If Application.Count(Range("G2:H20")) = 0 Then
Range("G2").Value = "No Results to Sort"
End If
End Sub

--
Regards,
Tom Ogilvy


"Max" wrote:

Within say, E2:F20 are formulas returning results that are always neatly
bunched at the top. Blank: "" lines (null strings) if any, would appear
below result lines within E2:F20.

What I would like to do is for a sub to copy only the result lines within
E2:F20 (omit the null string lines), then paste special as values into an
adjacent 2 col range ie into G2:Hn*, & sort the pasted range by col G,
ascending.
*n may vary from 2 to 20

And if there are zero result lines, ie E2:F20 contains only null strings,
then "No results to sort" will be written in G2. Thanks for insights.
--
Max
Singapore
http://savefile.com/projects/236895
xdemechanik
---



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
OMIT BLANK LINES WHEN FORCING A CARRIAGE RETURN --- PLEASE HELP! AfricanTigress Excel Worksheet Functions 5 June 6th 09 05:50 AM
copy formula down 1000,s of lines gfj Excel Worksheet Functions 2 November 5th 08 08:40 PM
Whats the quickiest way to copy a formula down 13,000 lines in exc IMF Excel Discussion (Misc queries) 3 June 18th 08 08:58 PM
Auto-copy of formula on inserted lines RizzKid Excel Discussion (Misc queries) 0 January 28th 08 03:13 AM
Macro to copy range of formulas to equal data lines lh Excel Worksheet Functions 2 August 15th 05 04:37 PM


All times are GMT +1. The time now is 11:21 AM.

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

About Us

"It's about Microsoft Excel"