VBA Vlookup missmatch. (Run-time error 13) - excel

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.)

Related

Using error handling within a formula which has multiple parts

I'm trying to implement error handling as part of the following formula, to account for cells in each range which simply don't have a value and return a "#NUM!" error:
{=SUMPRODUCT(R2:T2,U2:W2)/SUM(R2:T2)}
So far I've had some luck using IF and ISNUMBER combined (as shown below) when splitting up the main formula above, but I'm struggling when it comes to implementing it for each section/cell range. My attempt:
{=SUMPRODUCT(IF(ISNUMBER(R3:T3),R3:T3))}
Any help would be greatly appreciated!
Your original formula, without error handling, can be entered normally. It doesn't need Ctl+Shift+Enter. Nor can it produce a #NUM error because both the SUM() and SUMPRODUCT() functions interpret non-numeric values as zero. Therefore, if you get a #NUM error that error would be created by formulas in the range R2:W2. You should introduce error handling there, not in the formula we are looking at here.
The formula here - that is your first, original formula - will produce a Division by Zero error if SUM(R2:T2) equals zero. =IFERROR(SUMPRODUCT(R2:T2,U2:W2)/SUM(R2:T2),0) would return zero in case of such an error. You can modify the formula to something like =IFERROR(SUMPRODUCT(R2:T2,U2:W2)/SUM(R2:T2),"ERROR") if you prefer.
This kind of error handler would take effect also if an unhandled error is inherited from R2:W2. My recommendation is to handle errors where they occur but if you wish for a more specific error handler in the formula we are looking at here, the formula below would let imported #NUM errors pass and only handle #DIV BY ZERO errors produced by this formula.
=SUMPRODUCT(R3:T3,U3:W3)/IF(SUM(R3:T3),SUM(R3:T3),1)
This formula divides the result of the SUMPRODUCT() function by 1 if SUM(R3:T3) equals zero. This returns a result from the formula of 0 because the SUMPRODUCT part would return zero (unless it inherits a #NUM error).

GetPivotData #REF Error, data format issue?

I am getting a #Ref error when I try to reference an element from a pivottable.
I am literally doing a "=" and clicking on the pivot table to get the formula and even that is returning a #REF error.
To be a bit more specific, I am using a pivot table to sum up a datafield across some rows and columns. The columns have numbers formatted as string, so when I do the formula I get:
=getpivotdata("my_sum", ptable_ref, col_name, "COL_VAL", row_name, row_val)
COL_VAL is a number like 123, 234 but formatted as a string. Right now when I do the formula for "123" it works, but the same formula for "234" gives me a #REF error. If I leave off the quotes to use the number itself, I still get an error.
I've restarted excel and my computer, but that doesn't help. The data is being pulled from a database query, but col_name is the same format for all of them. I don't see any trailing or leading spaces either. I am scratching my head about what this could be. I'd rather not have to iterate through the rows for the values I need and just use the function to make it easy on myself.
If some of you are looking for an error handling (#ref error might be caused by filters):
=if(isError(formula);defaultValue;formula)
In Excel you can define names/variables for long expressions, e.g
formula=getpivotdata("my_sum", ptable_ref, col_name, "COL_VAL", row_name, row_val)

Vlookup in VBA via 'result'

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.

While extracting dates and numerics from mixed strings not able to remove zero from results.

I am extracting numerics and dates from a column containing mixed strings as shown in the sample table below.
Subscriber Name
123456789123 null null
null
null null null
5/23/2016
hello
Good Evening
null 6/11/2016
I am using the Array formula entering with CSE:
{=IFERROR(--SUMPRODUCT(MID(0&Q2,LARGE(INDEX(ISNUMBER(--MID(Q2,ROW($1:$25),1))* ROW($1:$25),0),ROW($1:$25))+1,1)*10^ROW($1:$25)/10),"")}
I am getting following results showing 0 in cells with empty or text cells whereas I require it to be empty. I have tried by inserting IFERROR and "--" also but I still get 0 in the cells. What correction is required in the formula. Further I am also open to VBA solution, if someone offers.
When no number is found your formula without the iferror is evaluating to 0 which is why you iferror is not catching anything. You could invert your results twice to cause an error when the results are zero. You know:
=1/BIG_HONKING_FORMULA
will give you a DIV/0! error for cells you want blank. You also know this will screw up the results for the rows you do want! so you could do:
=1/(1/BIG_HONKING_FORMULA)
which should generate an error when your formula is zero and should leave your results untouched for what you want to keep.

Excel Vlookup error

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

Resources