Search a range with 3 tables according to dropdown value - vba

I'm quite new to macros/formulae of excel. I have a sheet (Sheet1) exported which has the approvers list.
I also have 3 tables ( A, B, C)
In Sheet2 which has like below values:
Table A: {aaa,bbb,ccc}
Table B: {xxx,yyy,zzz}
Table C: {d12,e12,c12}
I need to search Column Q in sheet1 with either one table as per the dropdown menu.
If I select Table A, then I need to have all rows with text aaa OR bbb OR ccc in Column Q. I used the below formula, but I can search only one table at time.
I can't select through dropdown menu.
=SUMPRODUCT(--ISNUMBER(SEARCH(A[ID],Q51)))>0
This returns true or false. I have to keep changing the formulae for each table. Can I do that through drop down menu.

Use INDIRECT : place INDIRECT(Right(myRange, 1) & "[ID]") in the place of A[ID].
myRange is the address of the cell where the drop-down is placed; i.e. could be D1 for example, and the formula becomes:
=SUMPRODUCT(--ISNUMBER(SEARCH(INDIRECT(Right(D1, 1) & "[ID]"),Q51))) > 0

Related

How to use INDEX and MATCH to based to cells?

I have two sheets of data in excel. I want to combine cells to bring the second cell value. Here is an example:
when I enter combining columns name and list must get value form V1 and V2.like this:
I don't have the time to type your data, so this is a rare case of a non-tested formula and may need some tweaking.
For the V1 result: (top screenshot starts in Sheet1 column A, bottom screenshot in Sheet2, column A). This formula goes into cell B2 in Sheet 2:
=Index( Sheet1!$E$2:$E$100, MATCH(Sheet2!a2,INDEX(Sheet1!$A$1:$A$100&" | "&Sheet1!$D$1:$D$100,0),0))
Adjust the first index range from column E to F for the V2 result in C2.
Copy down.
Don't use that approach with whole columns. It will be slow. Use ranges with defined rows.
Of course, if the codes in Sheet1 column A are unique, you don't need to combine them with the value in column D and can look up only the first three characters, like this for V1 (use 6 for V2)
=vlookup(Left(Sheet2!A2,3),Sheet1!$A:$F,5,0)

Excel - Have a value from column B of a 2 column reference pasted anytime the value from column A is entered on a separate worksheet

In the example I have a 2 column reference where data in column E is correlated to column F. I need the data in Column F to show up anytime data from Column E is entered in a separate worksheet if possible.
To be clear, is it possible to enter data in Column A of Sheet 1 that pulls the correlated data from column B in reference Sheet 2 and enters it into Column B of Sheet 1?
I tried using a simple function in a single sheet but it obviously doesn't do what I need.
You are after VLOOKUP or INDEX MATCH
Sheet1 b1 and fill down rows
=IFERROR(VLOOKUP(A1,Sheet2!E:F,2,FALSE),TEXT(,))
Or
=IFERROR(INDEX(Sheet2!F:F,MATCH(A1,Sheet2!E:E,0)),TEXT(,))
If you set you data up as tables the formulas will autofill down. Rather than use entire columns you can set to the ranges containing data.
Data:

Excel Autofilter, Copy selection, Paste to new sheet

I have a table with source data in columns Regions!A6:R553.
In Regions!A3:R3, I have formulas that pull specific information out of my data table in Regions!A6:R553 that I want copied to a different sheet.
Column A acts as my project name column, while column B holds ID numbers. In my case, there are multiple ID numbers per project.
I am looking for a script to filter and loop through all the unique order numbers in Column B one by one, then copy cells A3:R3 to RegionsSummary!A12:R12 for as many rows as there are unique order numbers (i.e, add rows to the table).
Here is a screengrab of my data sheet, "Regions":
i.stack.imgur.com/aTPuw.png
Here is a screengrab of the empty template sheet "RegionsSummary":
i.stack.imgur.com/9Ukz5.png
Example: Assume there are 5 projects in my data sheet. I will filter the data using another macro to select Project_1. I would then like a command button to active a macro that will filter to the first order number in Column B, copy Regions!A3:R3 to RegionsSummary!A12:R12, then filter to the second order number in Project_1, and repeat the process. This should go on until all unique ID numbers have been filtered and looped through.
Here is a screengrab of what a final product should look like:
i.stack.imgur.com/9Ukz5.png
Here is a link to the file: Final Output Example
I would go with an easier solution than a Macro with certain constraints. I am not able to access your sheet, so I will make a sample excel.
STEPS:
Create a list of unique projects for a dropdown (COPY Regions!A5:A10000 to a new sheet > Data > Remove Duplicates) . Create the dropdown (Data Validation > List > Select Range) using Data Validation in "Example_Result" sheet- C7.
In "Regions", in Col S, put the below formula
=S6&"_"&COUNTIF($S$6:S6,S6)
Copy this formula down for the entire sheet or as long as you expect the sheet to grow
In "Example_Result", insert an index column (1 to 1000, in Col A if you expect each project to have 1000 or less order numbers) from A12 onwards.
Along the columns (B onwards) of Row 11 include the names of the variables from Regions (Assessment Project, Highway etc).
Insert the below formula in B12 to S1000 (depending on number of variables) of Example_Result:
=IFERROR(INDEX(Regions!$A$5:$S$10000,MATCH($C$7&"_"&A$12,Regions!$S$5:$S$10000,0),MATCH(B$11,Regions!$A$5:$H$5,0)),"")

look for Column heading and sum up

I have been working with a excel file with a lot of data, which is arranged in 2 sheets.
I would like to get data from sheet 1 to sheet 2 with reference to the column headings.
For example:
So if I want to find the sum of function 1 person A with criteria 1, the command have to go and find the heading "sum of function 1" in sheet 1 and choose the data that are only under criteria 1 and sum it up in sheet 2 cell D5. (By using column heading reference instead of cell reference).
The table range is A2 : U80.
Thanks.
First you have to format your data as table (select the data -> Menu Insert -> Table). Then you rename your table, for example Table1. Let's say one of the columns you want to sum on the sheet2 is called ColumnName.
On the sheet 2 you write a formula
=SUM(Table1[ColumnName])
The result will be what you are after.
You should try it by SUMIFS(). Syntax will be
=SUMIFS(AgeRange from sheet1,NameRange Sheet1, Name cell Sheet2, PlaceRangeSh1, Place Cell Sh2)
Tell me if requires further help.

VLOOKUP with button click

I'm trying to write some code for a button click to perform a VLOOKUP.
Sheet1 = Payment Form, Sheet2 = Global, Sheet3 = Details
Button will be on Sheet "Payment Form".
This would be the code for Cells in Global Sheet,
O1 = =VLOOKUP(BA,Details!A:H,8,0)
P1 = =VLOOKUP(BA,Details!A:H,6,0)
Q1 =VLOOKUP(BA,Details!A:H,5,0)
I need this to loop through all rows as the amount can change each month, if a match is found the perform the VlookUp, is no match is found, the delete the row from the Details Sheet.
For Example: Global, Cell B1 = 27801. In Details match found, then do the above codes from Columns O, P & Q.
Global, B2 = 27802. In Details no matching record found, row deleted. Continue to row 3 & 4 ......
what I suggest is you put all the value in table will be more efficient (not simply enter in the excel cell), you need create the table by INSERT ->Table. It will look like this :
Do this also for the Details :
Back to global worksheet, just need enter 1 row of formula, the rest of the rows in the same column will have the same formula "style"
Column O :=VLOOKUP([Column BA],Table2[[#All],[Column1]:[Column8]],8,FALSE)
Column P :=VLOOKUP([Column BA],Details!A:H,6,FALSE)
Column Q :=VLOOKUP([Column BA],Details!A:H,5,FALSE)
To remove the unwanted row, just filter out the blanks value in that columns will do.