2

Is there any way to call an Excel WorksheetFunction in Python win32com or any other libraries?

I would like to use formulas like VLookup/Match/Index/SumIfs in Python.

1 Answer 1

3

Yes. You can use the WorksheetFunction object on the Application object. For instance, in the particular case of Match, to find the first occurrence of 1.0 in 'B:B' in the first sheet of the first open workbook, you can do

import win32com.client
excel = win32com.client.Dispatch('Excel.Application')
workbook = excel.Workbooks(1)
worksheet = workbook.Worksheets(1)
excel.WorksheetFunction.Match(1.0, worksheet.Range('B:B'), 0)
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.