If One Function Returns Error Then Use Second Function
Feb 18, 2013I want a UDF; = OK (f1,f2) each argument being an alternative function. If f1 returns an error message then use f2. Should be easy but I cannot get it to work.
View 5 RepliesI want a UDF; = OK (f1,f2) each argument being an alternative function. If f1 returns an error message then use f2. Should be easy but I cannot get it to work.
View 5 RepliesIs there a way in which you can create an if function or similar to give a reason for why the cell of data has an error.
Basically i have some data in a table, and when a #num! error pops up id like to in the cell next to it give a sentence stating why this has happened.
E.G.
Cell A1 Cell B1
#Num! Number error due to 'x' being too small
Not sure how i can get this to work, i have tried a basic if function but that hasnt worked.
I have created a calculated column in PowerPivot and inserted a formula that worked in a normal excel spreadsheet however, this formula does not work in PP anymore.
=find("green",Table1[Name],1)
Name column:
NAME: Bag green
it should find "green" in the name and return the position. Hoever it alway returns the error, that the find function could not find the string.I have attached an example spreadsheet.
I have the following
Private Sub Workbook_Open()
Worksheets("Sheet1"). Range("L5").Value = Date
End Sub
When i try and run the code it returns an error saying: "Compile Error, Cant Find Project Or Library" and it highlights the word "Date"
Function Haversine has correct value in debugger but in cell it has the same value as Haversine2. Is this a known bug?
Public Function Haversine(lat1 As Double, long1 As Double, lat2 As Double, long2 As Double) As Double
Dim temp As Double
[Code]....
I am having some trouble getting a formula to work. I am building a report that pulls figures from a pivot table in another workbook. I am using a vlookup with match function to get the column index to find the relevant data I want. Where I need to add two columns together I am using sum, with the vlookup & match formulas nested in them e.g.:
=SUM(VLOOKUP(F13,'[PIVOT 156.xlsx]PIVOT'!$C:$AQ,MATCH("FAID",'[PIVOT 156.xlsx]PIVOT'!$C$6:$AQ$6,0),FALSE),VLOOKUP(F13,'[PIVOT 156.xlsx]PIVOT'!$C:$AQ,MATCH("COMM",'[PIVOT 156.xlsx]PIVOT'!$C$6:$AQ$6,0),FALSE),VLOOKUP(F13,'[PIVOT 156.xlsx]PIVOT'!$C:$AQ,MATCH("BPCM",'[PIVOT 156.xlsx]PIVOT'!$C$6:$AQ$6,0),FALSE),VLOOKUP(F13,'[PIVOT 156.xlsx]PIVOT'!$C:$AQ,MATCH("COMD",'[PIVOT 156.xlsx]PIVOT'!$C$6:$AQ$6,0),FALSE))
Where:
F13 = Employee number
Column C on the pivot 156 workbook is where the employee number is based.
The Match formula is then getting the column index from the column headings of the pivot table ie. "FAID"
This in itself works fine, as long as it finds a match in the column headings. This is where i get the error as in the above function "COMD" is not in the pivot table. However I need to keep it included as it may appear on a future pivot table. Is there a way of getting the sum function to complete even though later in the formula it can't complete the vlookup? So it will ignore it, or assume the value is zero if it can't find it? The formula probably needs to do this for all the vlookups as some headings may drop off in future pivot tables.
I keep getting the "You've entered too many arguments for this function" error.
Here is the formula:
=IF(B15=D40,E40,"",IF(B15=D41,E41,"",IF(B15=D42,E42,"","Invalid Shipping option")))
In column D I have the time of the end of my shift. When I try to input =MIN(1;$D:$D) in column E, i get the same answer (0,625) for any row, while =$D:$D gives correct values. So I guess it has something to do with the MIN function
View 10 Replies View RelatedHave a spreadsheet prepared by someone else on older Excel version exported from database. The sum and count functions work fine both vertically and horizontally, but trying to add selected cells returns #VALUE! Attached is small range of 50-col x 2500 row spreadsheet. Original content is highlighted in yellow. See cell E2. I assume the forumula is seeing number content as text. How do I convert the entire spreadsheet to numbers.
View 3 Replies View RelatedI am working on a Monthly Vehicle Spread Sheet. One of the outputs I am trying to achieve is an automatic calculation of Mile Per Gallon. To do this, I need to know if there is a function that will return the value of the first entry of a group of cells.
In calculating the miles per gallon, I need to subtract the first gallon amount entry of the total gallons in the month, then divide that number into the difference of the mileage in the month recorded when the vehicles fueled up.
I'm a newbie who has a simple "Area()" function that multiplies two numbers. I copied it off the Net as a programming test. I added to a Module of my Workbook using Tools>Macro>Visual Basic Editor. I put it in "Modules>Module1". Problem is, it doesn't seem to be recognized in my Workbook. When I enter "=Area(A1,A2)" into a cell (without the quotes) I get "#NAME?". What am I doing wrong? Here's the function:
View 6 Replies View RelatedI'm using the following phrase out of a much longer expression to
demonstrate that the return value of the MID function seems to be nothing I
can understand.
This expression:
=MID("6/10x",1,FIND("x","6/10x)-1))
returns 6/10 as text which makes sense. However I was under the impression
that when text in Excel contains numeric characters, it can be interpreted
as a number. So then how does the following expression,
=MID("6/10x",1,FIND("x","6/10x)-1)*1
return the result 38878? Does it still think it's text?
Im trying to do a lookup but when I drag the formula down it returns the wrong values and also returns #N/A or #REF (which I think means it's refering to a wrong range and cant find the data???). How can I do a look up function by dragging the formula down a long column of data eg. 65,000 rows in excel, that returns the correct text. I have attached a simple example- see attached.
View 4 Replies View Relatedi have a very basic function using instr as follows:
ins = 0
Dim x As Integer
Dim y As Integer
findst = "["
finden = "]"
x = InStr(ins, oldstrgFd, findst, vbTextCompare)
y = InStr(ins, oldstrgFd, finden, vbTextCompare)
Debug.Print x,y
oldstrgFd in the example is populated with
[ClientName] Planning Workshop
[FeedbackLocation], [FeedbackDate]
[FeedbackPresenters]
I am expecting this the first positions of the square brackets, but x and y both return 0.
when ltoj is less than zero the following code enters a period in the cell instead of zero.
If ltoj < 0 Then ltoj = 0
Cells(r, 10) = Format(ltoj * 24, "##.##") 'writes data in correct format
I am trying to get the week from a given data (from a cell that has been correctly formatted with date). =YEAR works, =MONTH works, =WEEKNUM does not work. I am using Excel 2003 and I have tried in both my workplace and at home...
I.e., I have a date in C2 (18-05-08), and =YEAR(C2) returns 2008, =MONTH(C2) returns 5, while =WEEKNUM(C2) returns #NAME, and =WEEKNUM(C2,2) does not work at all...
Let's say I have data that looks like this grid below. Each color represents a column heading and each number is a data point within that column.
Blue Red Green Yellow
18 27 15 36
56 41 3 22
Can I write a formula that would do the following 2 things with the data in this format:
1. Find the max of the data...simple =Max(...) formula
2. Use the max to return the column heading. In this case the max is 56 so the value I want to return is "Blue"
something that looks like =CELL.MIN(reference)
View 3 Replies View RelatedI've never quite mastered the idea of passing arguments between subs and functions. I have a project right now where I am writing this same bit of code over and over, for different parts of the macro:
View 4 Replies View RelatedI have calculated the t values then i have three tables for 3 confidence levels, 0.01, 0.05,0.1 in which I compare the t value with the value from the
t-test table. If the t value is larger it returns a 1, if not a 0. This works fine.
To summarise the information I have a final table which I wish to return the highest significance of the given t value.
I am using this
=IF((G53=1),0.01,(IF(G44=1,0.05,(IF(G35=10,0.05,"none")))))
the problem I have is it always returns 0.01 even if g53=0. If i remove the formula from g53 and replace it with a 0, it returns 0.05 instead (even if g44 is retruning a 0).
I have considered copy paste values and doing this but that rather removes the automation aspect of the spreadsheet if I need to make adjustments.
I have some survey data for 2008 & 2009. I have a column calculating the difference on each question between the two years. I need to show the 20 biggest changes, positive or negative. Which function can I use for this?
View 9 Replies View RelatedI've been asked to adjust some thing with a worksheet someone else created. On the sheet labeled "Criteria" there is a list of dates and some formulas that use these dates. I can't figure out why the result of the formula is a number, i.e "0"; I thought it is supposed to return "TRUE" or "FALSE". If I insert a new sheet, within the same workbook, and insert the same formula, I get "TRUE" or "FALSE". For some reason, the "Criteria" worksheet doesn't return "TRUE" or "FALSE", it returns numbers. I just need to know why this is happening so I can replicate it in the new workbook I'm creating.
View 2 Replies View RelatedIn the attached file I used =MATCH(TRUE,INDEX($B$2:$B$10="",0)) to retrieve the location of the first empty cell.
When using the "Evaluate Formula" tool, it is clear that the position in the array created by the INDEX function is the 6th. Nevertheless, the final outcome is 9, being the last cell in range.
I have this COUNTIFS expression buried in a larger formula:
COUNTIFS(Table[C7],Table[C7]&"",Table[C21],">=1")
and it always returns a value of zero or some positive integer.
I'm now looking for a little "function" that I can wrap around this expression that will:
A) indicate any non-zero result as 1 or TRUE
and
B) indicate any zero result as 0 or FALSE
Something like...
AREYOUNONZERO( (COUNTIFS(Table[C7],Table[C7]&"",Table[C21],">=1") )
I'm sure there's a fairly efficient way to do this... but I'm totally stumped at the moment!
I get a Type mismatch from this line:
x = Application.WorksheetFunction.Lookup(2, 1 / (Range("G7:P7") = "A"), Range("G7:P7"))
Is it possible to see why this code returns a date that is almost correct? Searching for 01.01.2005 I get 01.11.2005 as result. I would like the code to only show the correct date, and if it doesn't exist it should end up showing "nothing".
Code:
Set fstdate = wsOBX.Range("B1:B" & lr1).Find(what:=startdate, _
LookIn:=xlFormulas, lookat:=xlPart, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False)
I am trying to write a UDF that will calculate a value and return it to the cell, and also create a comment in the cell showing the formula used. Here is an example of the "=calculate(A2,B2)" placed in cell A1
Function calculate(ByRef X As Range,ByRef Y As Range)
calculate=x*y
calculate.addcomment "calculate = " & X & " * " & Y
End Function
the problem commes from the add comment field. I can add a comment to any cell but the cell the formula is called from.
I setup this function to pull my staff's schedule an auto generate the forms i need however the lookup function works properly sometimes and improperly others i checked the syntax and it is correct how ever the wrong data is continually returned. I have attached the file if anyone can help. the VISUAL PLAN tab is the one contaning the formula and it pulls data from PLAN, CURENT SCHEDULE, AND CATAGORY SUMMARY however the only formulas hat i have a problem with are the ones referencing CURENT SCHEDULE.
View 9 Replies View RelatedI'm compiling a list of names on a separate tab from a column that only lists the names sporadically. Problem: In the formula, the IF provides a TRUE, the row function, and consequently, the INDEX function (when I hit F9) provides the correct "name" and row number, but when I hit return, it provides the text 4 cells beneath what it should.
=IF(ROWS(F$5:F5)
If a INDEX,MATCH function returns a zero, how do I get it to use the value in the adjacent cell which is a unique number?
=INDEX(Sheet2!A:C,MATCH(A2,Sheet2!A:A,0),3)
Example: