{"id":18,"date":"2026-01-26T17:44:38","date_gmt":"2026-01-26T09:44:38","guid":{"rendered":"https:\/\/openpyxl.com\/blog\/?p=18"},"modified":"2026-01-16T06:24:05","modified_gmt":"2026-01-16T06:24:05","slug":"how-to-reference-a-cell-range-using-openpyxl","status":"publish","type":"post","link":"https:\/\/openpyxl.com\/blog\/how-to-reference-a-cell-range-using-openpyxl.html","title":{"rendered":"How To Reference a Cell Range Using OpenPyXL?"},"content":{"rendered":"<h2>Method<\/h2>\n<ul>\n<li>Given the coordinates of the top-left and bottom-right corners of a range, use these coordinates to reference the cell range. \u2013 A tuple of cell objects.<\/li>\n<li>Reference rows and columns \u2013 A tuple of cell objects.<\/li>\n<li>Use the `CellRange` class.<\/li>\n<\/ul>\n<h2>Sample Code<\/h2>\n\n\n<pre class=\"wp-block-code\"><code>#Referencing Cell Ranges\n\n#Import load_workbook function\nfrom openpyxl import Workbook\n\n#Create a new workbook\nwb=Workbook()\n#Get the active worksheet\nws=wb.active\n\n#Get a range of cells\ncr=ws&#91;'A1:C4']\n#Or\n#cr=ws&#91;'A1':'C4']\nprint(cr)\nprint(cr&#91;2]&#91;2].value)\n\nwb.save('test.xlsx')\nwb.close()<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>OpenPyXL<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-18","post","type-post","status-publish","format-standard","hentry","category-openpyxl-cell-range"],"_links":{"self":[{"href":"https:\/\/openpyxl.com\/blog\/wp-json\/wp\/v2\/posts\/18","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/openpyxl.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/openpyxl.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/openpyxl.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/openpyxl.com\/blog\/wp-json\/wp\/v2\/comments?post=18"}],"version-history":[{"count":2,"href":"https:\/\/openpyxl.com\/blog\/wp-json\/wp\/v2\/posts\/18\/revisions"}],"predecessor-version":[{"id":232,"href":"https:\/\/openpyxl.com\/blog\/wp-json\/wp\/v2\/posts\/18\/revisions\/232"}],"wp:attachment":[{"href":"https:\/\/openpyxl.com\/blog\/wp-json\/wp\/v2\/media?parent=18"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/openpyxl.com\/blog\/wp-json\/wp\/v2\/categories?post=18"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/openpyxl.com\/blog\/wp-json\/wp\/v2\/tags?post=18"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}