Skip to content Skip to sidebar Skip to footer

Find Range Of Filled Contents In Excel Worksheet

I have an Excel 2016 Book.xlsm. In the worksheet testsheet, the cells in the range A1:Y150 are filled with text or number contents. The upper-left cell is always A1. I am using pyt

Solution 1:

If wb is defined as Excel Workbook, then this is a good way:

print (wb.sheets[sheet_name].api.UsedRange.Address)

Solution 2:

You can get the range filled with contents with used_range:

import xlwings as xw

filename = "test.xlsx"

wb = xw.Book(filename)
ws = wb.sheets["SheetX"]
a_range = ws.used_range.address
print(a_range)

Post a Comment for "Find Range Of Filled Contents In Excel Worksheet"