[Min Value lookup across rows and columns in Excel]

anuradhagrewal

Board Regular
Joined
Dec 3, 2020
Messages
85
Office Version
  1. 2010
Platform
  1. Windows
Hi
I have a problem in finding the MINIMUM hrs worked by an employee week on week. For eg Employee Name "Kishore" appears in A2,A35,J34,G72 but what I need is in the output column the lowest hours Kishore has worked.
This is a repetitive process that has to be done week on week and with lots of data so using the Pivot table option is unfeasible.
The link of the data file is with the Data worksheet and the desired output worksheet here

What I was looking is MIN function based output.

Please guide.

Thanks

Regards

Anuradha
 

Attachments

  • result.png
    result.png
    69.4 KB · Views: 5

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Hello, is VBA an option?

I have tested the below an i think it might suit your requirements.

VBA Code:
Sub find_and_send()
Dim lr As Long, rng As Range, r As Range, sh As Worksheet, ws As Worksheet, cell As Range
Dim dict As Object
Set dict = CreateObject("Scripting.Dictionary")

Set sh = ThisWorkbook.Sheets("Data")
Set ws = ThisWorkbook.Sheets("Output Desired")
 
On Error GoTo errhandler
 
lr = sh.Cells.Find(What:="*", _
                    after:=sh.Range("A1"), _
                    LookAt:=xlPart, _
                    LookIn:=xlFormulas, _
                    SearchOrder:=xlByRows, _
                    SearchDirection:=xlPrevious, _
                    MatchCase:=False).Row
    
For Each cell In ws.Range("A2:A" & ws.Range("A" & Rows.Count).End(xlUp).Row)


For Each rng In sh.Range("A2:L" & lr)
    If rng.Value = cell.Value Then
        dict.Add Cells(1, rng.Column + 1), rng.Offset(0, 1).Value
    End If
Next

Min = Application.Min(dict.items)

cell.Offset(0, 1).Value = Min

dict.RemoveAll

nextcell:
    Next cell
    
Exit Sub

errhandler:
    cell.Offset(0, 1).Value = "No Value"
    Resume nextcell

End Sub
 
Upvote 0
Thanks Barry you are an life saver?...The code works..

I had a couple of queries regarding the VB script.
1)If I have data which is beyond column L to say column X then all I need to do is increase the range....plz advice

2)Please consider my foll query :If I need to look for min value in worksheet "data" in specific columns then how can we modify this code. For eg each corresponding to each week there is Avg Hrs Worked. In some new employees the week in which they have joined will have the same avg hrs worked Or in case of employees who are absent for a long duration there avg hrs worked will come across as min value as the value in the corresponding week will be blank.
Hence if it is possible can the VB script look up only in the specific column titled "wk(number)".

That is my concern

But in any case THANKS A TON BARRY:love:
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,733
Members
448,987
Latest member
marion_davis

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top