Limited scope VLookup

Demirion

Board Regular
Joined
Sep 21, 2022
Messages
66
Platform
  1. Windows
Hi. I have a table in which I assign team members to specific tasks using the vlookup. I would like to each team member should have 20 requests assigned. The rest of requests should receive the status "unassigned". What's the easiest way to do this?
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
How about something like this?

=IF( COUNTIF(TableRange, VLOOKUP("For Employe Name"))>20;"unassigned";VLOOKUP("For Employe Name"))
 
Upvote 0
Maybe but I don't know how use it. My vlookup looks like:
VBA Code:
Range("B2:B" & lastRow).Formula = "=VLOOKUP(A2,'" & wb1.Sheets("Sheet1").Name & "'!$A$1:$C & lastRow2 & ",2,False)"
 
Upvote 0
Maybe like this?

Range("B2:B" & lastRow).Formula =IF( COUNTIF("B2:B" & lastRow, VLOOKUP(A2,'" & wb1.Sheets("Sheet1").Name & "'!$A$1:$C & lastRow2 & ",2,False))>20;"unassigned";VLOOKUP(A2,'" & wb1.Sheets("Sheet1").Name & "'!$A$1:$C & lastRow2 & ",2,False))
 
Upvote 0
I don't know if this formula is correct. I have a syntax error. Can you take a look?
VBA Code:
.Range("B2:B" & lastRow).Formula = If(CountIf("B2:B" & lastRow, VLOOKUP(A2,'" & wb1.Sheets("Sheet1").Name & "'!$A$1:$C & lastRow2 & ",2,False))>20,"unassigned",VLOOKUP(A2,'" & wb1.Sheets("Sheet1").Name & "'!$A$1:$C & lastRow2 & ",2,False)
 
Upvote 0
There were misplaced quotation marks. Try like that:

VBA Code:
Range("B2:B" & lastRow).Formula = "=If(CountIf(B2:B" & lastRow & ", VLOOKUP(A2,'" & wb.Sheets("Sheet1").Name & "'!$A$1:$C" & lastRow2 & ",2,False))>20,""unassigned"",VLOOKUP(A2,'" & wb1.Sheets("Sheet1").Name & "'!$A$1:$C" & lastRow2 & ",2,False)"
 
Upvote 0
It works without syntax errors, but I got an error when I ran the macro "Application-defined or object-defined error". Maybe the data range is wrong? I have tried various options but cannot solve the problem.
 
Upvote 0
Yes workbook name or worksheet name can be wrong. Why do you want to go with VBA?

It is quite achievable with a regular formula.
 
Upvote 0
But in my earlier vlookup everything works fine. Something is wrong with this code, and I can't figure out what, if any, is correct.

Because I need to do a macro.

Can you send me some links on how to do it? Maybe I'll try to figure it out myself using a different method. Previously, I searched the internet but found little.
 
Upvote 0
My bad.
Fix the first one
VBA Code:
wb.Sheets("Sheet1").Name
It should be wb1 I guess
 
Upvote 0

Forum statistics

Threads
1,214,981
Messages
6,122,565
Members
449,089
Latest member
Motoracer88

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