Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Sheet doesn't recalculate after picking from list including own function

I have workbook with user VBA function (returning name of the cell):

Function cellName()
    cellName = ActiveCell.Offset(0, 0).Name.Name
    
End Function

I have a list dictList with 3 columns used as dictionary (cellNames; ENG equivalents; CZ equivalents)

I have a cell $P$1 including data validation that can contain EN/CZ value.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Each cell in the sheet that has specified name (=cellName) includes a function

=VLOOKUP(cellName();dictList;IF($P$1="CZ";2;3);FALSE)

Finally each named cell contains text in czech or english language based on its name and vlooked value in dictlist.

The problem occurs, when I switch in $P$1 from CZ to EN or vice versa.

The values with VLOOKUP formulas shows result #VALUE! until I press F2 and Enter on each cell.

I don’t want to press F2+enter on each cell after switching the language.

Tank you for your help.

Karel

When I put the result of cellName() directly to vlookup, then it works as expected. When I put there back my function, then it returns the #VALUE! again.

>Solution :

Untested, but instead of using ActiveCell, try using Application.ThisCell:

Returns the cell in which the user-defined function is being called from as a Range object.

Public Function cellName() As String
    cellName = Application.ThisCell.Name.Name
End Function
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading