View Single Post
  #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

Thanks again, Tom.

Went with this modification of your sub
which works well on the sheet.


Private Sub Worksheet_Calculate()
Dim i As Long
Dim r As Range
On Error GoTo ErrHandler
Application.EnableEvents = False
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.CountA(Range("G2:H20")) = 0 Then
Range("G2").Value = "No Results to Sort"
End If
ErrHandler:
Application.EnableEvents = True
End Sub

--
Max
Singapore
http://savefile.com/projects/236895
xdemechanik
---