Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 287
Default Range of Worksheet Function Max

I am using the following code to find the max value within a group of cells.
I would like for a variable to also be set as the range of that value. How
do I do that? Attached is my code and what I have tried. Thank you very
much.


wks_W.Range("DN" & m).Value = WorksheetFunction.Max(wks_W.Range("CM" & m &
":CO" & (n - 1)))

wks_W.Range("DO" & m).Value = WorksheetFunction.Max.Range(wks_W.Range("CM" &
m & ":CO" & (n - 1)))

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Range of Worksheet Function Max

Adam,

Try code similar to the following:

Dim MaxVal As Double
Dim MaxRng As Range
MaxVal = Application.WorksheetFunction.Max(Range("A1:A10"))
Set MaxRng = Range("A1").Offset( _
Application.WorksheetFunction.Match(MaxVal, Range("A1:A10"),
0) - 1)
Debug.Print MaxVal
Debug.Print MaxRng.Address


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Adam" wrote in message
...
I am using the following code to find the max value within a
group of cells.
I would like for a variable to also be set as the range of that
value. How
do I do that? Attached is my code and what I have tried.
Thank you very
much.


wks_W.Range("DN" & m).Value =
WorksheetFunction.Max(wks_W.Range("CM" & m &
":CO" & (n - 1)))

wks_W.Range("DO" & m).Value =
WorksheetFunction.Max.Range(wks_W.Range("CM" &
m & ":CO" & (n - 1)))



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Range of Worksheet Function Max

Dim rng as range, rng1 as Range
Dim maxVal as Variant
set rng = wks_W.Range("CM" & m & ":CO" & (n - 1))

maxVal = WorksheetFunction.Max(rng)

wks_W.Range("DN" & m).Value = maxVal
set rng1 = rng.Find(maxVal)
wks_W.Range("DO" & m).Value = rng1.Address

--
regards,
Tom Ogilvy


"Adam" wrote in message
...
I am using the following code to find the max value within a group of

cells.
I would like for a variable to also be set as the range of that value.

How
do I do that? Attached is my code and what I have tried. Thank you very
much.


wks_W.Range("DN" & m).Value = WorksheetFunction.Max(wks_W.Range("CM" & m &
":CO" & (n - 1)))

wks_W.Range("DO" & m).Value = WorksheetFunction.Max.Range(wks_W.Range("CM"

&
m & ":CO" & (n - 1)))



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
Variable named range in worksheet function Barb Reinhardt Excel Worksheet Functions 6 July 26th 08 03:39 AM
Worksheet function for range of numbers brendan_doc Excel Worksheet Functions 1 February 9th 06 06:15 PM
How do I sort a range of cells via a worksheet function RogerWilco Excel Worksheet Functions 3 January 11th 06 07:24 PM
Reference the worksheet from a multiple worksheet range function ( DBickel Excel Worksheet Functions 1 May 28th 05 03:49 AM
Range Question / error 1004: method Range of object Worksheet has failed Paul Excel Programming 3 April 7th 05 02:56 PM


All times are GMT +1. The time now is 08:55 AM.

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"