Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all articles
Browse latest Browse all 88066

How to copy data from one sheet to another while skipping empty cells - Python and Openpyxl

$
0
0

I'm using python to format an Excel spreadsheet. I need to copy data from Column L in Sheet #1, "Main", and paste it into Column A in Sheet #2, "Data". I've gotten this working, but I also want to skip empty cells, which occur randomly in Sheet #1, and here I ran intro trouble.

I tried:

for i in range(2, 50):
    for j in range(12, 13):
        if cell.value != None:
            data.cell(row=i, column=j-11).value = main.cell(row=i, column=j).value

However I get the error message "NameError: name 'value' is not defined"

Any ideas?


Viewing all articles
Browse latest Browse all 88066

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>