{"id":2365,"date":"2026-10-13T07:11:51","date_gmt":"2026-10-12T23:11:51","guid":{"rendered":"https:\/\/xlwings.net\/blog\/?p=2365"},"modified":"2026-03-29T09:57:32","modified_gmt":"2026-03-29T09:57:32","slug":"how-to-use-rangeautocomplete-in-the-xlwings-api-way","status":"publish","type":"post","link":"https:\/\/xlwings.net\/blog\/how-to-use-rangeautocomplete-in-the-xlwings-api-way\/","title":{"rendered":"How to use Range.AutoComplete in the xlwings API way"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">The <code>AutoComplete<\/code> member of the <code>Range<\/code> object in Excel is a property that enables or disables the automatic completion feature for a specific cell. This feature, when active, suggests possible entries based on previously entered data in the same column, helping to ensure consistency and speed up data entry. It is particularly useful in scenarios where users are inputting repetitive data, such as product names, categories, or employee IDs, as it reduces typing errors and minimizes the need for manual lookups. In xlwings, the <code>AutoComplete<\/code> property is accessed through the <code>api<\/code> property of a Range object, providing direct interaction with the underlying Excel object model.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The syntax for using <code>AutoComplete<\/code> in xlwings is straightforward. It is a read-write property that accepts a Boolean value. The xlwings API call format is <code>range.api.AutoComplete = value<\/code>, where <code>range<\/code> is an xlwings Range object representing a single cell (since AutoComplete applies per cell), and <code>value<\/code> is either <code>True<\/code> to enable automatic completion or <code>False<\/code> to disable it. For example, to check the current setting, you can retrieve it with <code>current_setting = range.api.AutoComplete<\/code>. It is important to note that this property is specific to Excel&#8217;s application-level settings for a cell and does not require additional parameters.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Below are practical xlwings API code examples demonstrating the use of the <code>AutoComplete<\/code> property. First, ensure xlwings is installed and an Excel workbook is open or created via xlwings.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import xlwings as xw\n\n# Connect to an existing workbook or create a new one\nwb = xw.Book() # Opens a new workbook\nsheet = wb.sheets&#91;'Sheet1']\n\n# Example 1: Enable AutoComplete for a specific cell (e.g., A1)\nrange_a1 = sheet.range('A1')\nrange_a1.api.AutoComplete = True\nprint(f\"AutoComplete enabled for A1: {range_a1.api.AutoComplete}\")\n\n# Example 2: Disable AutoComplete for another cell (e.g., B1)\nrange_b1 = sheet.range('B1')\nrange_b1.api.AutoComplete = False\nprint(f\"AutoComplete enabled for B1: {range_b1.api.AutoComplete}\")\n\n# Example 3: Check the AutoComplete status for multiple cells\nfor cell in &#91;'A1', 'B1', 'C1']:\n    cell_range = sheet.range(cell)\n    status = \"Enabled\" if cell_range.api.AutoComplete else \"Disabled\"\n    print(f\"AutoComplete for {cell}: {status}\")\n\n# Example 4: Toggle AutoComplete based on a condition (e.g., enable only if cell is empty)\ntarget_range = sheet.range('D1')\nif target_range.value is None:\n    target_range.api.AutoComplete = True\n    print(\"AutoComplete toggled to True for empty cell D1\")\nelse:\n    target_range.api.AutoComplete = False\n    print(\"AutoComplete toggled to False for non-empty cell D1\")\n\n# Save and close the workbook (optional)\nwb.save('example_autocomplete.xlsx')\nwb.close()<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The `AutoComplete` member of the `Range` object in Excel is a property that enables or disables the &#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[25],"tags":[],"class_list":["post-2365","post","type-post","status-publish","format-standard","hentry","category-xlwings-api-reference"],"_links":{"self":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/2365","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/comments?post=2365"}],"version-history":[{"count":1,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/2365\/revisions"}],"predecessor-version":[{"id":3604,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/2365\/revisions\/3604"}],"wp:attachment":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/media?parent=2365"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/categories?post=2365"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/tags?post=2365"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}