Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > BOOK: Excel VBA 24-Hour Trainer
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 6th, 2012, 11:00 AM
Registered User
Points: 5, Level: 1
Points: 5, Level: 1 Points: 5, Level: 1 Points: 5, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
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:

Sub dstc()

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:

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

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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

All times are GMT -4. The time now is 10:51 PM.

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