Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
DT DT is offline
external usenet poster
 
Posts: 20
Default mininum with referance

Hi,
I have three diff files with the data something like this.
first file
1.xls
12
34
56
78
45

2.xls
21
22
28
35

3.xls
25
66
33
58

i want to use some function which can find the minimum value from each row
of this file and then put the file name of the min value
eg for first row if 12 is the cheapest value , function should return 1.xls

please let me know if this is possible.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default mininum with referance

Is there only one worksheet per file (cells are located on worksheets, not
files)?

Where do you want the results placed. Next to the numbers in 1.xls? where?

Sub CompareBooks()
Dim v as Variant, i as Long, j as Long
Dim sh1 as Worksheet, sh2 as Worksheet
Dim sh3 as Worksheet, lastrow as Long
v = Array("1.xls","2.xls","3.xls")
i = lbound(v)
set sh1 = workbooks(v(i)).Worksheets(1)
set sh2 = workbooks(v(i+1)).Worksheets(1)
set sh3 = workbooks(v(i+2)).Worksheets(1)
lastrow = sh1.cells(rows.count,1).End(xlup).row
for j = 1 to lastrow
if sh1.cells(j,1) <= sh2.Cells(j,1) and _
sh1.Cells(j,1)<= sh3.Cells(j,1) then
sh1.cells(j,2) = v(i)
elseif sh2.cells(j,1) <= sh1.Cells(j,1) and _
sh2.Cells(j,1)<= sh3.Cells(j,1) then
sh1.Cells(j,1) = v(i+1)
else
sh1.Cells(j,1) = v(i + 2)
end if
Next j
end Sub

--
Regards,
Tom Ogilvy


"DT" wrote:

Hi,
I have three diff files with the data something like this.
first file
1.xls
12
34
56
78
45

2.xls
21
22
28
35

3.xls
25
66
33
58

i want to use some function which can find the minimum value from each row
of this file and then put the file name of the min value
eg for first row if 12 is the cheapest value , function should return 1.xls

please let me know if this is possible.

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
Circular Referance John Vickers Excel Discussion (Misc queries) 2 February 15th 06 08:56 AM
Showing Mininum $ for items woody Excel Worksheet Functions 2 November 1st 05 09:03 AM
cell referance darsg Excel Programming 1 May 13th 05 02:36 PM
How to referance a GroupName Garry[_7_] Excel Programming 3 October 5th 04 01:24 PM
Cross Referance Nathan[_3_] Excel Programming 1 November 7th 03 06:56 AM


All times are GMT +1. The time now is 08:10 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"