latestmonth sheet cell(row= column=lastcolvalue todocheck each member' payment status todolog in to email account todosend out reminder emails after importing the openpyxlsmtpliband sys moduleswe open our duesrecords xlsx file and store the resulting workbook object in wb then we get sheet and store the resulting worksheet object in sheet now that we have worksheet objectwe can access rowscolumnsand cells we store the highest column in lastcol wand we then use row number and lastcol to access the cell that should hold the most recent month we get the value in this cell and store it in latestmonth step find all unpaid members once you've determined the column number of the latest month (stored in lastcol)you can loop through all rows after the first row (which has the column headersto see which members have the text paid in the cell for that month' dues if the member hasn' paidyou can grab the member' name and email address from columns and respectively this information will go into the unpaidmembers dictionarywhich will track all members who haven' paid in the most recent month add the following code to sendduesreminder py #python sendduesreminders py sends emails based on payment status in spreadsheet --snip-check each member' payment status unpaidmembers { for in range( sheet max_row ) payment sheet cell(row=rcolumn=lastcolvalue if payment !'paid' name sheet cell(row=rcolumn= value email sheet cell(row=rcolumn= value unpaidmembers[nameemail this code sets up an empty dictionary unpaidmembers and then loops through all the rows after the first for each rowthe value in the most recent column is stored in payment if payment is not equal to 'paid'then the value of the first column is stored in name wthe value of the second column is stored in email xand name and email are added to unpaidmembers sending email and text messages