I am trying to do a Vlookup in VBA for a value in column D, ( it changes every cell) to match the values in column A on a different Tab, and to return the values in Column E that match the same value/row in column D. Why does the code below not work:
result = [VLOOKUP(Detail - All!D2,WOs to Del!A:A,1,false)]
Not enough info.... What error message, are you sure there's a match?
Your missing apostrophes around 'sheet names', start there. If you still bonk out then give us more information.
You can get error 2042 if your data doesn't actually have a match.
You could be getting a compile error from Option Explicit if "result" isn't declared.
But maybe you have "result" declared as a range and you're getting run time error 91.
I could go on, but really what's the point. You didn't share the information we need to identify everything that's broken.
Related
What I want is if Location and Case Number line up on Sheet1 and Sheet2, add in the Attorney information from Sheet2 to Sheet1. Here's a sample of the kind of data I'm dealing with:
Sample Data
We have repeated case numbers in multiple locations, so the data needs to match case number and location before inputting attorney names.
I stupidly deleted my previous attempts before thinking to ask for help, but I got pretty much every error in the book (#spill, #N/A, #ERROR, etc) I kept getting errors for VLOOKUP, and then I tried IFS, and still can't get anything to work.
My most recent attempt is:
Attempt
=IFS((A:A=Attorneys!A:A)AND(Sheet1!B:B=Attorneys!B:B), Attorneys!F:F)
Which resulted in #SPILL!
Then:
Adjusted Attempt
=#IFS((#A:A=#Attorneys!A:A)*AND(#Sheet1!B:B=#Attorneys!B:B),Attorneys!F:F)
Which resulted in most #N/A, but some random rows populated with one attorney's name, but none of the others.
I've done something similar before, but I was only trying to verify one column of data, not two, and that seems to be breaking my brain. I know I'm missing something really simple in here, but I just can't see it.
Edit:
I also tried Index because I forgot about that one, but I'm 99% sure I did it very incorrectly.
=INDEX(Attorneys!F:F,MATCH(A1&B1,Attorneys!A:A&Attorneys!B:B, 0))
And I got #N/A with no helpful information on the calculation error. This is the error I got: Index Error
Edit 2: I had a stray comma which was causing the error on the Index! I still have some random entries where it's #N/A instead of a name, and I need to check to verify that the data is populating correctly instead of just putting in a random name.
Final edit:
Index without typos did it!
=INDEX(Sheet2!F:F,MATCH(A2&B2,Sheet2!A:A&Sheet2!B:B,0))
Try index/match like:
=INDEX($C$2:$C$4,MATCH(A7,IF($B$2:$B$4=B7,$A$2:$A$4),0))
Thanks to u/findwindow, this is solved!
=INDEX(Sheet2!F:F,MATCH(A2&B2,Sheet2!A:A&Sheet2!B:B,0))
In my case, Sheet2 is called Attorneys, and I have headers so I skipped all of row 1.
In a for-loop after 50+ iterations I get the error With Vlookup in VBA.
And when debugging:
I tried to add the CStr() in the lookup value argument, but that did not help.
Range DB in the sheet:
Is it the two leading zeros that it cannot recognize in the table?
However, I have another case where the strings begins with letters and i still get the error. It seems so random, in a loop 3/74 rows give this error. I have verified that the values do exists in the DB range (but that should not be the problem either, because when looking up something random, it does not give a rune-time error, but the result-handle from vlookup contain the error.)
I've written a formula in excel which is able to find any specific text from a column, no matter how many times it has appeared. The issue I'm facing is that the cells which doesn't have the result show value error. How can I get rid of this value error? In the following example I tried to find "TORRES" from column A. Using my formula I get that in column B but the value error comes along like shown in the image.
Here is the formula I was trying with:
=IF(A1=SEARCH("TORRES",A1),A1,A1)
Here is the image containing results along with value error:
Btw, When nothing found I want those cells to be blank.
You're getting the VALUE error, because there's not always "TORRES" in the column.
You can hide that with IF(ISERR()):
=IF(ISERR(SEARCH("TORRES",A1)),"",A1)
Edit: Updated per your comment under the OP.
This will check if the SEARCH() finds TORRES. If it doesn't, returns "", if it does, it returns the value.
I have a spreadsheet that is stored in a shared location on a website that I need to do a Vlookup on in order to gather certain data. In order to test I have a Workbook stored in my documents. I have some VBA in this workbook but this does not affect the data in question.
The Formula that I am attempting is
=VLOOKUP("activated",$A4,4,TRUE)
What I need to do is to pull data from several columns in this sheet but I have not used Vlookup in a long time so I am trying to start small. I have formatted all of the cells to general but this has not helped.
I have also tried
=VLOOKUP("activated",$A2:$A71,4,TRUE)
However I constantly get the #REF error
Putting the following will return Activated so I know that in principal the formula is correct
=VLOOKUP("activated",$A2:$A71,1,TRUE)
I have looked at the answer submitted in Excel VLOOKUP #REF Error but this has not resulted in the correction of my errors
Any help would be greatly appreciated
The third argument is the column that you want to return... As there is only 1 column in the range $A2:$A71 you can't put 4 as the argument...
You probably need =VLOOKUP("activated",$A2:$D71,4,TRUE)
Also you should probably use FALSE for your last argument, as this can return the next closest match, if you use TRUE.
Range_lookup A logical value that specifies whether you want VLOOKUP to find an exact match or an approximate match:
http://office.microsoft.com/en-gb/excel-help/vlookup-HP005209335.aspx
I have a column of data that will have more values added to it over time. I would like to use this column's values for List validation on another worksheet, such that the drop-down options reflect the current contents of the column. I tried creating a named range ListColumn with the following formula:
=ADDRESS(3,12,1,1,"DataSource")&":"&ADDRESS(COUNTA('DataSource'!$L:$L),12,1,1,"DataSource")
When I try to add validation for a cell, choosing Allow: 'List' and entering =ListColumn in the formula box, I get this error message:
The list source must be a delimited list, or a reference to a single row or column.
I tried wrapping the whole formula in an INDIRECT(), and while that didn't generate an error on the Name Manager screen, when I tried to add the validation, I got this error message:
The Source currently evaluates to an error. Do you want to continue?
I'm not sure what's wrong here. The second parameter of both ADDRESS() calls is the same, so the range address should refer to a single column. How can I set up the dynamic list validation that I'm looking for?
EDIT: Debugging this is producing some odd behavior. I keep getting a run-time error when I try to select ListColumn using Range("ListColumn").Select. Message is "Method 'Range' of object '_Global' failed."
Entering =ListColumn returns: 'DataSource'!$L$3:'DataSource'!$L$65, which is the expected value.
Also, when I enter the formula =COUNTA(ListColumn) it returns "1", but when I enter the formula =COUNTA('DataSource'!$L$3:'DataSource'!$L$65) it returns the correct value of "63". =COUNTA(INDIRECT(ListColumn)) also returns "1".
I believe the issue may be the inclusion DataSource as the text sheet name in the second ADDRESS block. I get the exact same behavior as you do when performing your steps above, but it seems to work with this:
=INDIRECT(ADDRESS(3,12,1,1,"DataSource")&":"&ADDRESS(COUNTA(DataSource!$L:$L),12,1,1))
You can then do exactly what you did above and use it in a drop-down. My best assumption would be that since you are already defining the sheet in the first portion of the address, you do not need to provide it in the second portion (and it will cause an error if you do). If you think about it from a program perspective, it makes sense (I think :) ), since it would be difficult/impossible to refer to ranges over multiple sheets, and therefore the syntax likely doesn't allow for a second sheet to be specified after the colon (even if it is the same). That is just conjecture though (probably wrong), so hopefully the solution works :)