Passing a variable from Excel to Python with XLwings
Question: I am trying write a simple user defined function in Python that I pass a value
to from `Excel` via `Xlwings`. I ran across some examples with an Add-in that
you need to import user defined functions, but that seems overly complex.

Why isn't my example working?

VBA:

    
    
    Function Hello(name As String) As String
        RunPython ("import Test; Test.sayhi(name)")
    End Function
    

Python (`Test.py`):

    
    
    from xlwings import Workbook, Range
    
    def sayhi(name):
        wb = Workbook.caller()
        return 'Hello {}'.format(name)
    

Error:

    
    
    NameError: name 'name' is not defined
    


Answer: Make sure you're supplying the argument correctly:

    
    
    RunPython ("import Test; Test.sayhi('" &  name & "')") 
    

