Excel Function Error ???

Rolly_Sefu

Board Regular
Joined
Oct 25, 2013
Messages
149
Hello
I have created 2 functions


F1
Code:
Function special_txttonr(text As String)
Dim arr(), a As Long
    c = 0
For a = LBound(Split(text, ",")) To UBound(Split(text, ","))
  ReDim Preserve arr(a)
    arr(a) = CInt(Split(text, ",")(a))
    b = arr(a)
    x = WorksheetFunction.Max(b, c)
    c = x
Next a
special_txttonr = x
End Function


F2
Code:
Function checkifclosed(text As String)
    Dim arr(), atext As Long
    For atext = LBound(Split(text, ",")) To UBound(Split(text, ","))
      ReDim Preserve arr(atext)
        arr(atext) = CInt(Split(text, ",")(atext))
        If Range("F" & arr(atext) + 16) <> "" Then
            x = arr(atext)
        Else
            x = 0
            Exit For
        End If
    Next atext
checkifclosed = x
End Function


When I am on the sheet where the function are they bought evaluate perfectly.


But when i try to reference the cell ( in a lookup table from VLookup ) the F2 function shows "".


Does anyone have any idea why the F2 function it will not remain evaluated ?


Thanks
 
I will try this one last time. This line:

Code:
Range("F" & arr(atext) + 16)

refers to a cell in column F of whatever sheet is active at the time the function calculates. I assume it should refer to a specific sheet, but which one?
 
Upvote 0

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
The text it is splittling is "26,27,28,29" - witch is in the same sheet with the function ( bought in a cell )
It needs to check in the same sheet if row 26 + 16 is <> ""
So i suppose it is for the active sheet.
Yes it should only refer to sheets with the name from 1 to 15
 
Upvote 0
If it's the same sheet the function is entered in, you should use Application.Caller.Worksheet.Range and not just Range.
 
Upvote 0
Yes.


It's exactly what i needed. ( Vlookup does not return error anymore )


Thank you. And sorry for all the messages i did not explin the problem correctly.
 
Upvote 0
That's OK - we got there in the end, which is the main thing! :)
 
Upvote 0

Forum statistics

Threads
1,224,832
Messages
6,181,234
Members
453,026
Latest member
cknader

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top