I created a "IF Formula" in excel and wanted to convert that formula in function I read multiple article; but unable to convert formula into function: Formula is as follows:
=IF(LEFT(L3,4)=0321," 12 - ABC type",
IF(LEFT(L3,3)=021," 543 - XYZ type",
IF(ISERROR(SEARCH("T56_",L3))=FALSE,MID(L3,SEARCH("T56_",L3),19),
IF(ISERROR(SEARCH("MCW",L3))=FALSE,MID(L3,SEARCH("MCW_",L3),10),
"Logic Missing"))))
I just include the 4 IF's from the formula; but I have way more than 10 IF logic in the actual formula. Is there a way to create this IF formula in Function.
I already tried the below mentioned code but it gave me #VALUE! error.
Function AccountType(dCell As Variant) As Long
If dCell = Left(dCell, 4) = "0321" Then
AccountType = "12 - ABC type
ElseIf dCell = Left(dCell, 3) = "021" Then
AccountType = "543 - XYZ type"
Else
AccountType = "Logic Missing"
End If
End Function
As the comments stated remove the
dcell =
and make the function return aString
instead of aLong
. and you were missing a"
in the third line.