Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > BOOK: Excel VBA 24-Hour Trainer
|
BOOK: Excel VBA 24-Hour Trainer
This is the forum to discuss the Wrox book Excel VBA 24-Hour Trainer by Tom Urtis; ISBN: 978-0-470-89069-1
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Excel VBA 24-Hour Trainer section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 6th, 2012, 11:00 AM
Registered User
 
Join Date: Apr 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Distinct Values and variable dynamic range

Hi guys,

I would really appreciate if you could please help me solve a couple of things that drive me crazy.

1. I am trying to return the top 5 values from a list using this formula:

=INDEX($B$4:$B$12,MATCH(LARGE($B$4:$B$12,ROWS($F$4 :F4)),$B$4:$B$12,FALSE))

A4:A12 has A,b,c,d,e,f,g,h,i and B4:B12 has the values 10,15,15,7,5,20,18,18,3

Apologies, I tried to upload a file, but couldn't find the link to do it.

The formulas work, but if the two entries have the same value, my formula can't differentiate btw the two, and will list the same entry twice (15,18 repeat in col B)
Is there any way I can tweak the formula to give me the next name associated with the duplicate value?

2. I am trying to select a range whose end is variable. The end of the range is dependent on a formula that tries to find unique values. The fomula is =SUMPRODUCT(1/countif(rng, rng)
I am a newbie to VBA and I don't know how to insert the end of the range to display the result of the SUMPRODUCT formula.
My code is:

Code:
Sub dstc()

Sheets("Sheet1").Select
Sheets("Sheet1").Range("H4:H" & Sheets("Sheet1").Range("H1").Value).Select
Selection.FormulaArray = "=distinctvalues(rng_A,TRUE)"

End Sub

So far I've tricked it by pointing to a cell (H1) that displays the result of the sumproduct, but somebody may delete it someday. My dream is to have something such as:

Code:
Sheets("Sheet1").Range("H4:H" & formula ).Value).Select
I'm attaching the file and I am really thankful for any help.





Similar Threads
Thread Thread Starter Forum Replies Last Post
XSLT 1.0 distinct values JohnBampton XSLT 9 November 12th, 2009 11:02 AM
Adding Distinct Values 1.0 musman0047 XSLT 2 February 25th, 2009 04:48 PM
getting distinct values from attribute markus2000 XSLT 1 June 13th, 2006 03:06 AM
Defining a Dynamic Range using a variable Alseikhan Excel VBA 0 March 27th, 2006 02:26 AM
DISTINCT ntext Values fleming SQL Server 2000 2 July 23rd, 2005 06:58 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.