Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
JNW JNW is offline
external usenet poster
 
Posts: 480
Default Return top ten results

At work I've got a mileage chart with distances between around 90 resorts.
I've already got a userform set up to retrieve the distance between 2
selected resorts. What I'd like to add is the ability to list at the bottom
of the user box the ten closest resorts to the first chosen resort.

Logic says that I would have to pull a list of all of the distances from the
chosen resort, sort it, then get the top ten onto the userform. Although, I
haven't been able to get anything to work yet.

Your help is much appreciated.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default Return top ten results

Your description is a little thin but you can look at the LARGE worksheet
function which returns the ? largest value in an array of values...
--
HTH...

Jim Thomlinson


"JNW" wrote:

At work I've got a mileage chart with distances between around 90 resorts.
I've already got a userform set up to retrieve the distance between 2
selected resorts. What I'd like to add is the ability to list at the bottom
of the user box the ten closest resorts to the first chosen resort.

Logic says that I would have to pull a list of all of the distances from the
chosen resort, sort it, then get the top ten onto the userform. Although, I
haven't been able to get anything to work yet.

Your help is much appreciated.

  #3   Report Post  
Posted to microsoft.public.excel.programming
JNW JNW is offline
external usenet poster
 
Posts: 480
Default Return top ten results

OK, to clarify.

-I have a mileage chart giving distances (in miles) between resorts owned by
the company I work for.
-I would like to create a macro that returns the 10 closest resorts to a
chosen resort.

-The combo box that users select the chosen resort from is on a userform
-I would like the results to appear on the userform as well (either in
textboxes or as labels)
-The mileage chart is a 90x90 grid in a spreadsheet.

Let's say that 'Las Vegas' is the chosen resort... Upon chosing this result
the macro would look in the row containing all of the corresponding
distances, determine the 10 shortest distances, match those distances to the
corresponding resorts, and display them on the the userform.

Thanks again in advance.

"Jim Thomlinson" wrote:

Your description is a little thin but you can look at the LARGE worksheet
function which returns the ? largest value in an array of values...
--
HTH...

Jim Thomlinson


"JNW" wrote:

At work I've got a mileage chart with distances between around 90 resorts.
I've already got a userform set up to retrieve the distance between 2
selected resorts. What I'd like to add is the ability to list at the bottom
of the user box the ten closest resorts to the first chosen resort.

Logic says that I would have to pull a list of all of the distances from the
chosen resort, sort it, then get the top ten onto the userform. Although, I
haven't been able to get anything to work yet.

Your help is much appreciated.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 50
Default Return top ten results

How do you want to handle ties?
--
Jim


"JNW" wrote:

OK, to clarify.

-I have a mileage chart giving distances (in miles) between resorts owned by
the company I work for.
-I would like to create a macro that returns the 10 closest resorts to a
chosen resort.

-The combo box that users select the chosen resort from is on a userform
-I would like the results to appear on the userform as well (either in
textboxes or as labels)
-The mileage chart is a 90x90 grid in a spreadsheet.

Let's say that 'Las Vegas' is the chosen resort... Upon chosing this result
the macro would look in the row containing all of the corresponding
distances, determine the 10 shortest distances, match those distances to the
corresponding resorts, and display them on the the userform.

Thanks again in advance.

"Jim Thomlinson" wrote:

Your description is a little thin but you can look at the LARGE worksheet
function which returns the ? largest value in an array of values...
--
HTH...

Jim Thomlinson


"JNW" wrote:

At work I've got a mileage chart with distances between around 90 resorts.
I've already got a userform set up to retrieve the distance between 2
selected resorts. What I'd like to add is the ability to list at the bottom
of the user box the ten closest resorts to the first chosen resort.

Logic says that I would have to pull a list of all of the distances from the
chosen resort, sort it, then get the top ten onto the userform. Although, I
haven't been able to get anything to work yet.

Your help is much appreciated.

  #5   Report Post  
Posted to microsoft.public.excel.programming
JNW JNW is offline
external usenet poster
 
Posts: 480
Default Return top ten results

I did somewhat of a work around. It's not as clean as I'd like it, but it
works. Let me know if there is anything that can be done to make this more
succinct.


My steps:
-Resort is selected from combo box
-HLookup function in worksheet to return all distances to other resorts
-"=IF(E2120,E212,"")" Next to above results to get rid of overseas resorts
that have a zero balance.
-then I used the SMALL function to pick out the 10 smallest values.

-In a userform I've got the combo box with a button next to it.
-the following headers (rank, resort, miles)
-Then when the resort is chosen and the button pushed the following code
executes:

Private Sub ButtonCalc_Click()
On Error GoTo ErrRoutine
With Sheets("Mileage Info")
ClosestResort01.Caption = .Range("M212").Value
ClosestMiles01.Caption = .Range("L212").Value
ClosestResort02.Caption = .Range("M213").Value
ClosestMiles02.Caption = .Range("L213").Value
' ' continues for all ten top results......
End With
ErrRoutine:
If Err.Number = "13" Then
MsgBox "There is no data for this location at the moment. Please
choose another location"
Exit Sub
End If
End Sub



"JNW" wrote:

At work I've got a mileage chart with distances between around 90 resorts.
I've already got a userform set up to retrieve the distance between 2
selected resorts. What I'd like to add is the ability to list at the bottom
of the user box the ten closest resorts to the first chosen resort.

Logic says that I would have to pull a list of all of the distances from the
chosen resort, sort it, then get the top ten onto the userform. Although, I
haven't been able to get anything to work yet.

Your help is much appreciated.

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
function to return two different results Haz Excel Discussion (Misc queries) 2 September 17th 07 03:44 PM
Compare and Return Results Electronic Lady Excel Discussion (Misc queries) 10 March 28th 07 07:28 PM
Vlookup to return results of If statement ruthhicks999 Excel Worksheet Functions 0 February 27th 07 11:25 AM
Return last 6 results formula [email protected] Excel Worksheet Functions 2 March 19th 06 07:04 PM
in EXCELL, the function does not return results IRINA Excel Worksheet Functions 2 January 20th 06 05:04 PM


All times are GMT +1. The time now is 07:00 PM.

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"