Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default finding min with currency

here is my original question

ok here is what i have.

A B C D E
1 V W X Y
2 1.95 1.55 1.75 2.05 #Display


now in cell E2 i want it to find the minimum value from A2 to D2 and
display the letter above that minimum values column found in row 1
(V,W,X or Y).


so in this example i want W to be displayed in Cell E2.

and this is the reponse i got


Sub test()
Dim rng As Range
Worksheets("Sheet1").Range("A2:D2").Select
Set rng = Selection.Find(What:=Application.min(Selection),
Lookat:=xlWhole, LookIn:=xlValues)
Range("E2") = rng.Offset(-1, 0)
End Sub

and it does work but now when i format the cells with the numbers in
them to currency it gives me a runtime error of 91. what do i need to
change in the code for it to work?

thank you
jonathan

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default finding min with currency

Maybe you could use a worksheet formula in E2:

=INDEX(A1:D1,MATCH(MIN(A2:D2),A2:D2,0))

Or try changing lookin:=xlvalues to lookin:=xlformulas

I think I'd drop the .select's, too:

Option Explicit
Sub test()
Dim myCell As Range
Dim myRng As Range

With Worksheets("sheet1")
Set myRng = .Range("A2:D2")
Set myCell = myRng.Find(What:=Application.Min(myRng), _
Lookat:=xlWhole, LookIn:=xlFormulas)
.Range("E2") = myCell.Offset(-1, 0)
End With
End Sub

wrote:

here is my original question

ok here is what i have.

A B C D E
1 V W X Y
2 1.95 1.55 1.75 2.05 #Display

now in cell E2 i want it to find the minimum value from A2 to D2 and
display the letter above that minimum values column found in row 1
(V,W,X or Y).

so in this example i want W to be displayed in Cell E2.

and this is the reponse i got

Sub test()
Dim rng As Range
Worksheets("Sheet1").Range("A2:D2").Select
Set rng = Selection.Find(What:=Application.min(Selection),
Lookat:=xlWhole, LookIn:=xlValues)
Range("E2") = rng.Offset(-1, 0)
End Sub

and it does work but now when i format the cells with the numbers in
them to currency it gives me a runtime error of 91. what do i need to
change in the code for it to work?

thank you
jonathan


--

Dave Peterson
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
How to add new currency Symbol in Format/Cell/Currency NOORZAD Excel Discussion (Misc queries) 2 June 22nd 09 07:59 AM
how do I sum currency values in a row containing currency and uni. Eusebius Excel Worksheet Functions 2 November 13th 08 01:35 PM
Currency kaxx23 Excel Discussion (Misc queries) 1 April 19th 06 05:36 PM
Conversion from currency value to currency text format Frank Kabel Excel Programming 1 August 18th 04 10:06 PM
Currency jes Excel Programming 1 January 5th 04 08:24 PM


All times are GMT +1. The time now is 07:53 PM.

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"