ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Cell address (https://www.excelbanter.com/excel-programming/316003-cell-address.html)

Neil[_11_]

Cell address
 
Hi!

How do I find the address of the cell that contains the minimum value in a
range.

Thanks in advance,

Neil



Myrna Larson

Cell address
 
In VBA? Assuming this is a 2-dim range rather than a single column or single
row,

Set Rng1 = Range("A1:K22")
x = Application.Min(Rng1)
Set Rng2 = Rng1.Find(What:=x, After:=Rng1.Cells(Rng1.Cells.Count))
MsgBox Rng2.Address


On Sat, 06 Nov 2004 22:49:31 GMT, "Neil" wrote:

Hi!

How do I find the address of the cell that contains the minimum value in a
range.

Thanks in advance,

Neil



Neil[_11_]

Cell address
 
Myrna,

Thanks for that, I just had to change it a little for my data to update a
chart and I was using a single row.

Set rng1 = Range(Cells(userrow, 19), Cells(userrow, 22))
x = Application.Min(rng1)
x1 = Application.Max(rng1)
With rng1
Set c = .Find(x, LookIn:=xlValues)
Set c1 = .Find(x1, LookIn:=xlValues)
End With
MinX = ActiveSheet.Range(c.Address).Address
MaxX = ActiveSheet.Range(c1.Address).Address

Thanks
Neil

"Myrna Larson" wrote in message
...
In VBA? Assuming this is a 2-dim range rather than a single column or
single
row,

Set Rng1 = Range("A1:K22")
x = Application.Min(Rng1)
Set Rng2 = Rng1.Find(What:=x, After:=Rng1.Cells(Rng1.Cells.Count))
MsgBox Rng2.Address


On Sat, 06 Nov 2004 22:49:31 GMT, "Neil" wrote:

Hi!

How do I find the address of the cell that contains the minimum value in a
range.

Thanks in advance,

Neil





Myrna Larson

Cell address
 
These lines can be shortened
MinX = ActiveSheet.Range(c.Address).Address
MaxX = ActiveSheet.Range(c1.Address).Address

to
MinX = c.Address
MaxX = c1.Address

With a single row, I personally would use MATCH, like this:

Set Rng1 = Range(Cells(userrow, 19), Cells(userrow, 22))

x = Application.Min(Rng1)
MinX = Rng.Cells(Application.Match(x, Rng1, 0)).Address

x = Application.Max(Rng1)
MaxX = Rng.Cells(Application.Match((x, Rng1, 0)).Address


On Sun, 07 Nov 2004 03:56:03 GMT, "Neil" wrote:

Myrna,

Thanks for that, I just had to change it a little for my data to update a
chart and I was using a single row.

Set rng1 = Range(Cells(userrow, 19), Cells(userrow, 22))
x = Application.Min(rng1)
x1 = Application.Max(rng1)
With rng1
Set c = .Find(x, LookIn:=xlValues)
Set c1 = .Find(x1, LookIn:=xlValues)
End With
MinX = ActiveSheet.Range(c.Address).Address
MaxX = ActiveSheet.Range(c1.Address).Address

Thanks
Neil

"Myrna Larson" wrote in message
.. .
In VBA? Assuming this is a 2-dim range rather than a single column or
single
row,

Set Rng1 = Range("A1:K22")
x = Application.Min(Rng1)
Set Rng2 = Rng1.Find(What:=x, After:=Rng1.Cells(Rng1.Cells.Count))
MsgBox Rng2.Address


On Sat, 06 Nov 2004 22:49:31 GMT, "Neil" wrote:

Hi!

How do I find the address of the cell that contains the minimum value in a
range.

Thanks in advance,

Neil





Neil[_11_]

Cell address
 
Myrna,

Thanks a lot. It now works beautifully.

Neil

"Myrna Larson" wrote in message
...
These lines can be shortened
MinX = ActiveSheet.Range(c.Address).Address
MaxX = ActiveSheet.Range(c1.Address).Address

to
MinX = c.Address
MaxX = c1.Address

With a single row, I personally would use MATCH, like this:

Set Rng1 = Range(Cells(userrow, 19), Cells(userrow, 22))

x = Application.Min(Rng1)
MinX = Rng.Cells(Application.Match(x, Rng1, 0)).Address

x = Application.Max(Rng1)
MaxX = Rng.Cells(Application.Match((x, Rng1, 0)).Address


On Sun, 07 Nov 2004 03:56:03 GMT, "Neil" wrote:

Myrna,

Thanks for that, I just had to change it a little for my data to update a
chart and I was using a single row.

Set rng1 = Range(Cells(userrow, 19), Cells(userrow, 22))
x = Application.Min(rng1)
x1 = Application.Max(rng1)
With rng1
Set c = .Find(x, LookIn:=xlValues)
Set c1 = .Find(x1, LookIn:=xlValues)
End With
MinX = ActiveSheet.Range(c.Address).Address
MaxX = ActiveSheet.Range(c1.Address).Address

Thanks
Neil

"Myrna Larson" wrote in message
. ..
In VBA? Assuming this is a 2-dim range rather than a single column or
single
row,

Set Rng1 = Range("A1:K22")
x = Application.Min(Rng1)
Set Rng2 = Rng1.Find(What:=x, After:=Rng1.Cells(Rng1.Cells.Count))
MsgBox Rng2.Address


On Sat, 06 Nov 2004 22:49:31 GMT, "Neil"
wrote:

Hi!

How do I find the address of the cell that contains the minimum value in
a
range.

Thanks in advance,

Neil








All times are GMT +1. The time now is 06:17 PM.

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