Last active
January 22, 2022 21:00
-
-
Save Elijas/2430813d3ad71aebcc0c83dd1f130e33 to your computer and use it in GitHub Desktop.
xlwings find used range boundaries (last used row and last used column)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import xlwings as xl | |
import xlwings.constants | |
s = xl.Book('doc.xlsx').sheets[0] | |
RR2 = s.api.Cells.Find(What="*", | |
After=s.api.Cells(1, 1), | |
LookAt=xlwings.constants.LookAt.xlPart, | |
LookIn=xlwings.constants.FindLookIn.xlFormulas, | |
SearchOrder=xlwings.constants.SearchOrder.xlByRows, | |
SearchDirection=xlwings.constants.SearchDirection.xlPrevious, | |
MatchCase=False) | |
RR = s.api.Cells.Find(What="*", | |
After=s.api.Cells(1, 1), | |
LookAt=xlwings.constants.LookAt.xlPart, | |
LookIn=xlwings.constants.FindLookIn.xlFormulas, | |
SearchOrder=xlwings.constants.SearchOrder.xlByColumns, | |
SearchDirection=xlwings.constants.SearchDirection.xlPrevious, | |
MatchCase=False) | |
print((RR2.Row, RR.Column)) | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey!
I found this code while trying to find a way to select the used range of a sheet. I came up with something I thought could be useful to others: