View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.misc
Ken Johnson Ken Johnson is offline
external usenet poster
 
Posts: 1,073
Default Help! How can I do this?

Hi Patrick,

I forgot to answer your question re supporting named ranges. My
experience with coding with named ranges is limited so I decided to
have a go. Here's the result...

Public Sub ListSoldTitles()
'This version relies on two named ranges on the
'sheet named "extended"...
'Name = "Titles" which refers to ALL of the book titles
'Name = "Sold" which refers to list of "Yes"/"No"
'You still need to edit the value of the string constant
'strDestination at the end of the next line
Const strDestination As String = "A" '<< edit to suit
Application.ScreenUpdating = False
With Worksheets("breakdown")
.Columns(strDestination).ClearContents
'Add 'Sold Titles' heading to breakdown sheet
.Cells(1, strDestination) = "Sold Titles"
End With
Dim I As Long
Dim J As Long
Dim rgCell As Range
For Each rgCell In Worksheets("extended").Range("Sold")
I = I + 1
If UCase(rgCell.Value) = "YES" Then
J = J + 1
Worksheets("breakdown").Cells(J + 1, strDestination).Value _
= Worksheets("extended").Range("Title").Cells(I, 1).Value
End If
Next rgCell
Worksheets("breakdown").Columns(strDestination).Au toFit
End Sub

How's that for code shrinkage:-)

WIth named ranges all the hard work is done by excel, rather than the
programmer.

I assume you are using dynamic named ranges. They certainly make life a
lot easier.

Ken Johnson