Forum Discussion

lynxtra's avatar
lynxtra
Copper Contributor
Jul 27, 2024

Python (preview) in excel

How do I get the result of an if statement into the cell where I've selected the python script to display the result?

 

I've so far used this script, it only displays in the diagnostic preview pane

 

 

 

 

a = xl("A1")
if a == xl("L1"):
     print("That's a match")

 

 

 

I want to display this in cell A2

6 Replies

  • SergeiBaklan's avatar
    SergeiBaklan
    Diamond Contributor

    lynxtra 

    print only put information into the right message pane.

    Into the grid last variable is returned. In your case it could be

    Don't forget to return value, not object (see '123' ).

    Since you have no else, if no match error will be returned

    • lynxtra's avatar
      lynxtra
      Copper Contributor

      SergeiBaklan  I kind of know that, but I'm asking if there's a way to put the result into the cell I put the python code

      • SergeiBaklan's avatar
        SergeiBaklan
        Diamond Contributor

        lynxtra 

        If Python code is in cell A2 result of the code will be returned in A2, no other options.

Resources