ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Return of Cell Location (https://www.excelbanter.com/excel-programming/433205-return-cell-location.html)

William Wolfe

Return of Cell Location
 
I am running VB code in Excel 2007. I execute a min function and now I want
to know what cell contained the min value.

How do I do this?

Thanks,



Gary''s Student

Return of Cell Location
 
Perhaps something like:

Sub FindMin()
Set r = Selection
v = Application.WorksheetFunction.Min(r)
For Each rr In r
If rr.Value = v Then
MsgBox (rr.Address)
Exit Sub
End If
Next
End Sub

--
Gary''s Student - gsnu200902


"William Wolfe" wrote:

I am running VB code in Excel 2007. I execute a min function and now I want
to know what cell contained the min value.

How do I do this?

Thanks,




slarbie

Return of Cell Location
 
If you didn't want to use code, you could just apply a filter to the range
included in the MIN function and look for the MIN value in the filter
selection list.

"William Wolfe" wrote:

I am running VB code in Excel 2007. I execute a min function and now I want
to know what cell contained the min value.

How do I do this?

Thanks,




Chip Pearson

Return of Cell Location
 
Try some code like

Dim R As Range
Set R = Range("C5:C10") '<<< CHANGE
Set R = R.Offset(Application.Match( _
Application.Min(R), R, 0) - 1, 0).Resize(1, 1)
Debug.Print R.Address

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)







On Thu, 3 Sep 2009 13:21:46 -0400, "William Wolfe"
wrote:

I am running VB code in Excel 2007. I execute a min function and now I want
to know what cell contained the min value.

How do I do this?

Thanks,



All times are GMT +1. The time now is 10:28 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com