Hello, 1st Time Poster Here...
I work in a warehouse that assigns certain areas to individuals so that they are responsible for their own sections. The way the bins (Warehouse locations) are named are easily sortable in Excel so that part is good. I would like to create a function that evaluates a bin name and assigns an area owner's name based on which range they fall into. This is a table that breaks down the ranges (Min & Max String Values) so that if I run the function and it is >= the Min and <= the Max it should assign that person's name:
[table="width: 500, class: grid, align: center"]
[tr]
[td]Min[/td]
[td]Max[/td]
[td]Area Owner[/td]
[/tr]
[tr]
[td]F38-01[/td]
[td]F41-20[/td]
[td]Matt[/td]
[/tr]
[tr]
[td]R01-01A[/td]
[td]R01-16H[/td]
[td]Jim[/td]
[/tr]
[tr]
[td]R01-17A[/td]
[td]R01-32H[/td]
[td]Dio[/td]
[/tr]
[tr]
[td]R01-33A[/td]
[td]R01-68H[/td]
[td]Matt[/td]
[/tr]
[tr]
[td]R02-01A[/td]
[td]R03-68H[/td]
[td]Bryan[/td]
[/tr]
[tr]
[td]R04-01A[/td]
[td]R05-68H[/td]
[td]Tom[/td]
[/tr]
[tr]
[td]S01-01A[/td]
[td]S02-04E[/td]
[td]Matt[/td]
[/tr]
[tr]
[td]Y01-01[/td]
[td]Y01-10[/td]
[td]Matt[/td]
[/tr]
[/table]
Right now I just want the evaluation part to run and bring up a message box with the Area Owner's name. I'm fairly new to VBA but I gave it a try and came up with an error. Can someone please take a look at my function and let me know how far off I am?
Thank you!
Note: A user on another forum suggested I just use Vlookup but unfortunately this won't work as this function is going to be part of a much bigger Macro and I want it to be somewhat "smart". Plus there are thousands of locations in this warehouse so the list would be huge and always changing.
I work in a warehouse that assigns certain areas to individuals so that they are responsible for their own sections. The way the bins (Warehouse locations) are named are easily sortable in Excel so that part is good. I would like to create a function that evaluates a bin name and assigns an area owner's name based on which range they fall into. This is a table that breaks down the ranges (Min & Max String Values) so that if I run the function and it is >= the Min and <= the Max it should assign that person's name:
[table="width: 500, class: grid, align: center"]
[tr]
[td]Min[/td]
[td]Max[/td]
[td]Area Owner[/td]
[/tr]
[tr]
[td]F38-01[/td]
[td]F41-20[/td]
[td]Matt[/td]
[/tr]
[tr]
[td]R01-01A[/td]
[td]R01-16H[/td]
[td]Jim[/td]
[/tr]
[tr]
[td]R01-17A[/td]
[td]R01-32H[/td]
[td]Dio[/td]
[/tr]
[tr]
[td]R01-33A[/td]
[td]R01-68H[/td]
[td]Matt[/td]
[/tr]
[tr]
[td]R02-01A[/td]
[td]R03-68H[/td]
[td]Bryan[/td]
[/tr]
[tr]
[td]R04-01A[/td]
[td]R05-68H[/td]
[td]Tom[/td]
[/tr]
[tr]
[td]S01-01A[/td]
[td]S02-04E[/td]
[td]Matt[/td]
[/tr]
[tr]
[td]Y01-01[/td]
[td]Y01-10[/td]
[td]Matt[/td]
[/tr]
[/table]
Right now I just want the evaluation part to run and bring up a message box with the Area Owner's name. I'm fairly new to VBA but I gave it a try and came up with an error. Can someone please take a look at my function and let me know how far off I am?
Thank you!
Code:
Public Function AreaOwnerSort(bin1)
Dim bin1 As String
Dim aOwner As String
Const floorMin As String = "F38-01"
Const floorMax As String = "F41-20"
Const rack1aMin As String = "R01-01A"
Const rack1aMax As String = "R01-16H"
Const rack1bMin As String = "R01-17A"
Const rack1bMax As String = "R01-32H"
Const rack1cMin As String = "R01-33A"
Const rack1cMax As String = "R01-68H"
Const rack23Min As String = "R02-01A"
Const rack23Max As String = "R03-68H"
Const rack45Min As String = "R04-01A"
Const rack45Max As String = "R05-68H"
Const secureMin As String = "S01-01A"
Const secureMax As String = "S02-04E"
Const yardMin As String = "Y01-01"
Const yardMax As String = "Y01-10"
If (bin1 >= floorMin) And (bin1 <= floorMax) Then
aOwner = "Matt"
ElseIf (bin1 >= rack1aMin) And (bin1 <= rack1aMax) Then
aOwner = "Jim"
ElseIf (bin1 >= rack1bMin) And (bin1 <= rack1bMax) Then
aOwner = "Dio"
ElseIf (bin1 >= rack1cMin) And (bin1 <= rack1cMax) Then
aOwner = "Matt"
ElseIf (bin1 >= rack23Min) And (bin1 <= rack23Max) Then
aOwner = "Bryan"
ElseIf (bin1 >= rack45Min) And (bin1 <= rack45Max) Then
aOwner = "Tom"
ElseIf (bin1 >= secureMin) And (bin1 <= secureMax) Then
aOwner = "Matt"
ElseIf (bin1 >= yardMin) And (bin1 <= yardMax) Then
aOwner = "Matt"
End If
MsgBox Str(aOwner)
End Function
Note: A user on another forum suggested I just use Vlookup but unfortunately this won't work as this function is going to be part of a much bigger Macro and I want it to be somewhat "smart". Plus there are thousands of locations in this warehouse so the list would be huge and always changing.