VBA Selecting a cell based of multiple critera - excel

I am trying to find a way to reference a cell in VBA based on two other cells in the datasheet.
In the datasheet I have a domain (D) column e.g. "example.com" and I have a date column (A) e.g. 01/01/2017
In my main worksheet I have a table with domains in column A and the dates in row 10. I am trying to find a to pick the cell in the table that falls into the date and domain based on the record it is currently looking at in the datasheet
Using that first line of data here is the an image highlighting the cell which I want to select.
My plan is to then copy the detail from the [Pass] column into that cell, I am just having problem selecting that cell.
I've tried as many solutions as I can find on here, most using one set of criteria, but I cannot seem to get them to work for me in this situation.
Many thanks
Dummy data
edit - added dummy data - had to remove screenshot of the data as I can only upload two links

Assuming your Sheet2 is as follows
Then, in Sheet1 enter the following formula in Cell E2
=INDEX(Sheet2!$A$10:$AH$17,MATCH(D2,Sheet2!$A$10:$A$17,0),MATCH(A2,Sheet2!$A$10:$AH$10,0))
Drag/Copy down as required. Change range as needed. See image for reference.
EDIT : As per comment
Enter this formula in Cell Z14
=INDEX(Sheet1!$C$2:$C$5,MATCH(A14,Sheet1!$D$2:$D$5,0))

Related

Can you create Excel hyperlinks to specific values/words within cells?

I'm creating a large spreadsheet for my job and need to create an Index at the top which links to specific sections of the workbook. I know how to link to cells within a spreadsheet - however, this spreadsheet will be consistently adding and removing rows, meaning the cell numbers will be changing.
Is there a way to create a hyperlink to a specific value/word within a cell? For instance, can I create a link to a cell with the header phrase "Transactions List," that will always link their even if its cell number changes?
Yes, there is way. You can use Match() function within Hyperlink() function to refer cell dynamically. Lets demonstrate how to do. Suppose you have Transactions List (see attached screenshot below) word in Column F and you want to hyperlink that cell even when you add few rows before that cell. Match function will find row number of cell containing Transactions List in specified column and link to that cell by below formula.
=HYPERLINK("#F"&MATCH("Transactions List",F:F,0),"Hello Hyperlink")
Even you can hyperlink cell in another sheet by following formula. Change sheet name in your case.
=HYPERLINK("#Sheet2!F"&MATCH("Transactions List",Sheet2!F:F,0),"Hello Hyperlink")

If a cell in column A in sheet 2 equal to a value from sheet 1 then return the values from sheet 2 to column B and c in sheet 1

I am looking to do a kind of automatic cell updates on excel, which is a status update for a product we got and the location of the product in the warehouse.
I have basic knowledge of VBA and I didn't manage to code anything to help me with that. I tried to use If function, but didn't make sense because I can't find a way to achieve what I need.
Here is sheet 1
and sheet 2
examples.
This is what I am trying to achieve:
if a cell within Sheet2 column A range = Cell A2 in sheet 1, then fill Sheet1, B2 cell and Sheet1, C2 cell with the information from sheet2 on the condition that it is the most recent entry (in the example images it is the entry with the dispatched status)
Would you recommend VBA or using formulas, and if so what should I do?
This can be done with formulas, however getting the latest value isn't as easy as it seems. This can be achieved however by following this tutorial for reference. I especially refer to the part using LOOKUP(.
Other than that, all you need to do is set your ranges to refer to the correct sheet.
=IFNA(LOOKUP(2,1/(Sheet2!A:A=Sheet1!A2),Sheet2!B:B),"")
My formula in B2 is:
=INDEX(Sheet2!$B:$B;MAX(SI(Sheet2!$A:$A=Sheet1!A2;ROW(Sheet2!$A:$A)-MIN(ROW(Sheet2!$A:$A))+1)))
My formula in C2 IS:
=INDEX(Sheet2!$C:$C;MAX(SI(Sheet2!$A:$A=Sheet1!A2;ROW(Sheet2!$A:$A)-MIN(ROW(Sheet2!$A:$A))+1)))
Both formulas are array formulas so instead of entering them with ENTER, they must be entered pressing
ENTER+CTRL+SHIFT at same time
Anyways, these formulas will probably make your file heavy and slower. Think about redesigning the way you save data, and consider adding a date field, and resuming data with Pivot Tables.

Excel - Counting no of items in a different sheet between a certain range matching specific criteria

I have been building up an excel sheet to interrogate a data set and produce a set of metrics. I'm aiming to make the process as expandable as possible.
In the links are pictures of a simple mock up data set to illustrate what I'm trying to achieve, it contains a metrics sheet where I want to display the information and the data set sheet:
and the
The aim is to have the highlighted cell (D6) display the number of items in "Sheet2" that meet the criteria of Item Status "Open".
I have managed this at first with the formula:
COUNTIFS(Sheet2!C:C,"Open")
and then to make it more expandable using:
COUNTIFS(INDIRECT(" ' "&D4&" ' !C:C "),"=" &C8)
This means I can use a cell (D4) to reference the sheet I want to look in and a cell (C8) to reference the criteria I want to search for. This works well until I need to look for blanks in the data set, at which point it counts all the blanks in the column specified (see cell D8 in metrics sheet).
So I was wondering if there would be a neat way to specify the column range to look in, eg C1:C100, by using cells to reference the range similar to using the cells to reference sheet and criteria. I can use the below formula but it still requires the sheet name to be written in the formula rater than referenced out to a cell.
COUNTIF((Sheet2!C1:INDIRECT(CONCATENATE("Sheet2!C", B2))),""&C8)
When I apply this to the data sets I'm looking at I will need to consider multiple sheets where the data sets will contain the same criteria (located in the same column across all sheets) but the data set will vary in length. This is why I'd like to keep the cell formula referencing the variables out to specific cells in the metrics sheet so that if I add in a new data set or criteria that I want to look at I don't have to re-type a load of formula but just copy it across.
UPDATE
Following the answer from JvdV I have been able to remove all the variables from the formula into cells in the metrics sheet (useful for what I'm doing and may be of interest to others). It essentially uses the 'INDIRECT' and 'CONCAT' functions to build the string needed, colour coded picture
Here is something you can try to suit your needs:
The formula I used in F1 would translate to:
=COUNTBLANK(INDIRECT(G1&"C1:C"&COUNTA(INDIRECT(G1&"A:A"))))
Cell G1 is just a list like:
If you don't want to have all used rows but use the range specified in your cell B2 then I guess it would look like:
=COUNTBLANK(INDIRECT(G1&"C1:C"&B2))
Beware; using INDIRECT() causes your formula to be volatile!

Vlookup formula in excel

I was hoping someone could offer me a little help please on a formula. In one of my cells I use a vlookup to search for the colour in B12 and match it to the colour on another worksheet called cars.
Now this works perfectly fine, but after running the formula I have to select the last row of data and press control & d, or drag down the cell up until the last cell, my question is that is it possible to add this forumla into the cell and have it automatically run all the way down to the last row of data? my forumula is
=VLOOKUP(B12,coloursc:carsc,2)
You can use an Excel table for your data entry. Formulas and formatting will automatically be applied to any new row in the table. You no longer need to manually copy down or pre-fill empty areas of the spreadsheet with formulas.
Learn more about tables in this Microsoft article and this tutorial on Contextures.com

VLOOKUP & Inserting Text That Corresponds To The Cell

I'm having difficulty getting my vlookup formula to pull url data from another sheet (Sheet 2) and insert added information to the url based on what is in its A cell on Sheet 1.
For example,
The vlookup formula =VLOOKUP(B2,Sheet2!A:B,2,FALSE) will check to see if B2 (Sheet 1) matches with Data on Sheet 2. It will then return the data it has matched:
=HYPERLINK("http://www.dpd.co.uk/tracking/quicktrack.do?search.consignmentNumber="&Sheet1!A2&"&search.searchType=16&search.javascriptValidated=0&appmode=guest")
I then want the url link to insert whatever text is in the Sheet 1 A cell.
The formula I have used does this nicely, but I want the formula to correspond down the workbook for whatever is in cell A, not just A1 i.e. Sheet 1 A3,Sheet 1 A4....
How can I do this?
Thanks
I'm not sure if I completely understand what you are asking but allow me to share my experience with what I believe was a similar problem.
My solution was an offset/match formula. I used a formula similar to:
=OFFSET($A$1,(MATCH(B$2,'Sheet2'!$A:$B,0)+$A1),0)
And had a list of values in column A that corresponded to the distance that row was to the object cell I wanted to keep constant. Then I used autofill to fill column a down the sheet as far as I filled the formula. This way offset refrence changed on each row and I was still able to auto fill.
I hope that helps

Resources