Complex VLOOKUP with dynamic sheet name - vba

I'm trying to perform a vlookup across multiple sheets in an elegant way, rather than with a vlookup nested in an IF function.
Column A has the account number and Column I has the manager responsible for that account. Each Manager has their own sheet. I was hoping to make vlookup look at a specific manager's sheet, find the account number in Column A, and return the info in Column K. I tried to use INDIRECT to make it do that:
=VLOOKUP($A2,INDIRECT($I2 & "!$A:$P"),11,FALSE)
With this code, I keep getting #REF instead of what is in Column K in the manager's sheet. How can I fix this?
Thanks!

I can't see your spreadsheet but if your sheets are named after managers I am willing to bet that those sheet names have some kind of character( like space) that forces referencing sheets in single quotes.
Assuming that is correct simply change your formula to:
=VLOOKUP($A2,INDIRECT("'" & $I2 & "'!$A:$P"),11,FALSE)
Also you can diagnose this issue with "Evaluate Formula" located in "Formulas>Formula Auditing", in there step through all steps that this formula has, and note when does that error shows up.

Related

Look for a word of column 1 and then search that word in another column of another excel sheet and use the adjacent information to fill the cell

I am trying to organize the data into one sheet. I am looking for a way through which I will be able to extract the potential failure mode from 2nd sheet to the first sheet. The key point is that the potential failure mode should match with its respective component. So the list of components is mentioned. A way through which Potential failure modes of that respective component is detected in another excel sheet and the information which is available in the adjacent column to be extracted on the first sheet.
Your problem is going to be solved with the function =VLOOKUP
Since you are hiding your column and sheet names, I am making some assumptions (assuming the first pic is called Sheet2 PAF is on column B and PFM is on column C). Try on Sheet1!D3 the following formula
=VLOOKUP(A3,Sheet2!B:C,2)
and it will fill in the FPM if a match of Sheet1!A3 is found in Sheet2!B column. You may want further reference
https://support.office.com/en-us/article/vlookup-function-0bbc8083-26fe-4963-8ab8-93a18ad188a1

VLookup across two workbooks

I've read many posts, but haven't quite found exactly the code that works (I'm new to VBA and unsure about proper syntax). What I have and what I need is simple. In one workbook, I have a list of names and email addresses (names in Column "A" and email addresses in Column "B"). In the second workbook, I have names in Column "A" (which come from the first workbook), but am missing some email addresses. I need to perform a VLookup so that the missing email addresses get pulled into the second workbook. The first workbook changes daily and feeds only the new names to the second workbook; I need to bring in the corresponding email addresses associated with the new names. Sounds simple, but I can't get the macro to work. Any help would be appreciated! Thanks.
Use the macro recorder enter a Vlookup formula into a cell. Stop the macro recorder. Now you have the syntax for Vlookup in VBA. Loop through your data grid and execute the Vlookup when the target cell is empty.

VBA - How to find frequencies of "x" and "y" in a list

I have a column of names on one page of an excel workbook, I need to find how often each of these names appears in that column and display it on another sheet. For example, the code needs to count "CS" however many times it appears in this column and display it on a separate sheet, then the same with "Grad" and so on. Any tips?
Thanks a lot
That's the primary use of Pivot tables.
Found the solution with a simple function
=COUNTIF(Individual_Stats!D6:D999,"CS")

Changing Formula sheet reference with Macro

Hello everyone i'm new to this site! i wanted to see if anyone could assist with a concept i believe is possible but don't know how to achieve it.
Essentially i have a formula that has Vlookups and references other sheets, this formula is the same but the sheet referenced changes for each column as each column references a different sheet. this is going to be done 135 times over 8 times.
=IF((IFERROR(VLOOKUP(D3,'[2015_Big_Book_Communication_10_19_15.xlsx]**Credit P-1**'!$C$2:$O$5000,9,FALSE),"Not Scheduled"))=0,1,IFERROR(VLOOKUP(D3,'[2015_Big_Book_Communication_10_19_15.xlsx]**Credit P-1**'!$C$2:$O$5000,9,FALSE),"Not Scheduled"))
I want to use a macro to change the bolded sheet reference based upon a cell.
my idea is to have all the sheet names listed in a column and have the macro edit the equation for each row and then just paste the formulas transposed.
Is this possible?
Use the following formula:
=IF((IFERROR(VLOOKUP(D3,INDIRECT("'[2015_Big_Book_Communication_10_19_15.xlsx]"&H3&"'!$C$2:$O$5000"),9,FALSE),"Not Scheduled"))=0,1,IFERROR(VLOOKUP(D3,INDIRECT("'[2015_Big_Book_Communication_10_19_15.xlsx]"&H3&"'!$C$2:$O$5000"),9,FALSE),"Not Scheduled"))
In a column ("col H" in this example) write the sheet names and use indirect formula to refer to those names.

VBA to transfer a figure from one sheet to another based on matching values other col

I am working on a spreadsheet which is being used to transfer a product from one location to another. Each day I will have a new list of products that needs sending to another location and I already have a "pre-populated" sheet that has suitable locations listed for where these products can be sent to.
I've already worked out the formula's to use which defines the location these products can be sent to (through index and match formula) but once this has been completed, I'd like to update the "pre-populated" sheet with the quantity I'm sending these locations so that limits can be deducted accordingly.
Essentially, I want to copy the figure from column G in ("Task") into column I in ("interstore transfer") where the two "REF" columns in either sheet match. The "New Limit" column will then automatically populate with the new limit based on the figure input into Column I. Once its finished working its way down the list in the sheet ("Task") then end.
I've had a rough attempt at this, but I'm coming stuck with defining the appropriate variables and how it should update.
Any ideas to better my approach would be appreciated.
A VBA solution with variables may not be your best approach for this. Variables declared within VBA code usually have a limited lifetime based on their scope, so when the code ends the values in the variable will be lost.
Another alternative may be to set aside another cell as a counter. Perhaps a good place for this would be next to the "New Limit" column?
Cell values are retained even when VBA code isn't running. Of course cell values also are saved when the workbook saves, so when you get a new list of products at the beginning of the day you can compare to or edit the previous day's work.
To get started with this, I'd recommend getting familiar with how to reference cells and ranges. And, there is some useful information here on Stack Overflow on how to reference well in Excel VBA.