{"id":2429,"date":"2026-11-14T07:34:26","date_gmt":"2026-11-13T23:34:26","guid":{"rendered":"https:\/\/xlwings.net\/blog\/?p=2429"},"modified":"2026-03-29T10:40:41","modified_gmt":"2026-03-29T10:40:41","slug":"how-to-use-rangeshowerrors-in-the-xlwings-api-way","status":"publish","type":"post","link":"https:\/\/xlwings.net\/blog\/how-to-use-rangeshowerrors-in-the-xlwings-api-way\/","title":{"rendered":"How to use Range.ShowErrors in the xlwings API way"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">The <code>ShowErrors<\/code> property of the <code>Range<\/code> object in Excel is a useful tool for data validation and error checking within a worksheet. When working with formulas, Excel can display various error values such as <code>#DIV\/0!<\/code>, <code>#N\/A<\/code>, <code>#NAME?<\/code>, <code>#NULL!<\/code>, <code>#NUM!<\/code>, <code>#REF!<\/code>, and <code>#VALUE!<\/code>. The <code>ShowErrors<\/code> property allows you to draw attention to these errors by applying a specific border style around cells that contain them. This visual indicator can help users quickly identify and correct problematic cells in large datasets. In xlwings, you can access and manipulate this property through the <code>api<\/code> property of a Range object, which provides direct access to the underlying Excel object model.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Syntax in xlwings:<\/strong><br><code>range.api.ShowErrors<\/code><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>This property is both readable and writable. It returns or sets a Boolean value (<code>True<\/code> or <code>False<\/code>).<\/li>\n\n\n\n<li>When set to <code>True<\/code>, Excel draws a border around cells in the specified range that contain formula errors. When <code>False<\/code>, the border is removed.<\/li>\n\n\n\n<li>The property applies to a <code>Range<\/code> object, which can be a single cell, a range of cells, or an entire worksheet area.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Parameters:<\/strong><br>The <code>ShowErrors<\/code> property does not take additional parameters. It is a simple Boolean property that toggles the error-indicating border on or off for the given range.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Example Usage in xlwings:<\/strong><\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Enabling Error Borders:<\/strong><br>To highlight formula errors in a specific range, such as A1:D10, you can set the <code>ShowErrors<\/code> property to <code>True<\/code>. This will draw borders around any cells within that range that contain errors.<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>import xlwings as xw\n\n# Connect to the active workbook and sheet\nwb = xw.books.active\nws = wb.sheets&#91;'Sheet1']\n\n# Define the range\ntarget_range = ws.range('A1:D10')\n\n# Enable error borders for the range\ntarget_range.api.ShowErrors = True<\/code><\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>Checking Current Status:<\/strong><br>You can also read the current status of the <code>ShowErrors<\/code> property to determine if error borders are already applied to a range.<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code># Check if error borders are enabled for the range\nstatus = target_range.api.ShowErrors\nprint(f\"ShowErrors enabled: {status}\") # Output: True or False<\/code><\/pre>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li><strong>Disabling Error Borders:<\/strong><br>To remove the error borders from a range, simply set the property to <code>False<\/code>.<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code># Disable error borders for the range\ntarget_range.api.ShowErrors = False<\/code><\/pre>\n\n\n\n<ol start=\"4\" class=\"wp-block-list\">\n<li><strong>Applying to Entire Worksheet:<\/strong><br>If you want to apply error highlighting to an entire worksheet, you can use the <code>UsedRange<\/code> property to get all cells with data and then set <code>ShowErrors<\/code>.<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code># Apply error borders to all used cells in the worksheet\nws.used_range.api.ShowErrors = True<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The `ShowErrors` property of the `Range` object in Excel is a useful tool for data validation and er&#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-2429","post","type-post","status-publish","format-standard","hentry","category-xlwings-api-reference"],"_links":{"self":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/2429","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=2429"}],"version-history":[{"count":1,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/2429\/revisions"}],"predecessor-version":[{"id":3689,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/2429\/revisions\/3689"}],"wp:attachment":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/media?parent=2429"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/categories?post=2429"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/tags?post=2429"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}