title: How to read excel files in a for loop with openpyxl?
body: <p>This seems tricky for me. Let's say I have, nested in a directory tree, an excel file with a few non-empty columns. I want to get the sum of all values located in column F with <code>openpyxl</code>:</p>
  
  <pre><code>file1.xlsx
  A  B  C  D  E  F
                 5
                 7
                 11
                 17
                 20
                 29
                 34
  </code></pre>
  
  <p>My take on it would be as follows, but it is wrong:</p>
  
  <pre><code>import os
  from openpyxl import load_workbook
  
  directoryPath=r'C:\Users\MyName\Desktop\MyFolder' #The main folder
  os.chdir(directoryPath)
  folder_list=os.listdir(directoryPath)
  for folders, sub_folders, file in os.walk(directoryPath): #Traversing the sub folders
      for name in file:
          if name.endswith(".xlsx"):
              filename = os.path.join(folders, name)
              wb=load_workbook(filename, data_only=True)
              ws=wb.active
              cell_range = ws['F1':'F7'] #Selecting the slice of interest
              sumup=0
              for row in cell_range:
                  sumup=sumup+cell.value
  </code></pre>
  
  <p>While running this I get <code>NameError: name 'cell' is not defined</code>. How to work around this?</p>