how to find if last row has value for a specific column in Excel using Python Win32com -



how to find if last row has value for a specific column in Excel using Python Win32com -

i have excel file , utilize python win32com operate on it.

how check if lastly row has value in specific column ?

when seek , nrows 28, not 23 (the lastly row have value not empty)

used = sht1.usedrange nrows = used.row + used.rows.count - 1

usedrange not reliable when want lastly row of specific column. should utilize endxlup or endxldown function.

check below line:

lastrow = sheets("sheet1").range("a" & sheets("sheet1").rows.count).end(xlup).row

where, column lastly row.

also, check url: error finding lastly used cell in vba

as using python win32 com, endxlup not work. there's 1 basic thing can do. check below code:

ws = wb.worksheets('sheet1') rw = 2 while ws.cells(rw, 1) <> "" rw +=1

where, rw starting row want start row count. 1 in (rw, 1) represents column. column represents a.

logic behind while loop run till not blank cell in column , row count in variable rw

python excel win32com

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -