0

Is there any way to run in Pyhton the equivalent of this Excel VBA code:

For i= 1 to 10
    'do some stuff
    'Refresh calculations in order to check the outcome

Next i

In other words: is it possible to refresh sheet formula results from within python, then rinse and repeat ? I tried saving as excel file and re-opening after each iteration, but it is too time consuming to begin with.

1
  • This is far too vague. What exactly are you trying to do? What do you mean by "refresh sheet formula results"? What is the purpose of the spreadsheet? The best way to solve your problem in Python might not involve spreadsheets at all. But if the question is "how do I manipulate spreadsheets in Python?", then it seems you are asking for a tool recommendation - those are off-topic for Stack Overflow, and better answered by either a search engine or e.g. some Reddit community. Commented Jun 21, 2020 at 15:35

1 Answer 1

1

You can run VBA without Excel. Just save the code into a file and use the windows built in command vbscript.

https://www.faqforge.com/windows/run-vbscript-windows/

You can run the command via subprocess.

If you want to run code in Excel, you have to write an Excel addon in python. There is an open source library called xlwings: https://www.xlwings.org/

(there is also a premium version of xlwings but you do not need them)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.