How to find the last row in a column using openpyxl normal workbook

0 votes
I'm doing data validation to all rows that include "Default" using openpyxl. However, I need to know how many rows there are in order to do that.

I am aware that there is a way to accomplish that if I were using iterable workbook mode, but I also want to add a new sheet to the workbook, which is not possible in iterable mode.
Dec 25, 2022 in Others by Kithuzzz
• 38,000 points
6,556 views

1 answer to this question.

0 votes

ws.max_row will give you the number of rows in a worksheet.

Since version openpyxl 2.4 you can also access individual rows and columns and use their length to answer the question.

len(ws['A'])

Though it's worth noting that for data validation for a single column Excel uses 1:1048576.

answered Dec 25, 2022 by narikkadan
• 63,600 points

Related Questions In Others

0 votes
1 answer

Another method to extract the last row containing data in a column

The "used range" might not be accurate. ...READ MORE

answered Mar 28, 2023 in Others by Kithuzzz
• 38,000 points
590 views
0 votes
1 answer
0 votes
1 answer

In excel how do I reference the current row but a specific column?

Put a $ symbol in front of ...READ MORE

answered Oct 15, 2022 in Others by narikkadan
• 63,600 points
1,923 views
0 votes
1 answer

How to find a value in an excel column by vba code Cells.Find

Just use: Dim Cell As Range Columns("B:B").Select Set cell = ...READ MORE

answered Nov 17, 2022 in Others by narikkadan
• 63,600 points
3,765 views
0 votes
1 answer

ImportError: openpyxl is required for loading excel format files

Forget the PsychoPy complications for the time ...READ MORE

answered Oct 3, 2018 in Python by Priyaj
• 58,020 points
1,078 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,434 views
0 votes
1 answer

How to insert a new row in the specified cell only, of Excel sheet using c#?

I have this worksheet with a matrix ...READ MORE

answered Nov 24, 2022 in Others by narikkadan
• 63,600 points
2,339 views
0 votes
1 answer

How to freeze the top row and the first column using XlsxWriter?

You can use worksheet.freeze_panes() to achieve this . There ...READ MORE

answered Oct 11, 2022 in Others by narikkadan
• 63,600 points
2,310 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP