Yes, you can remove borders by selecting the range and running a short VBA macro, or by recording a macro that deletes the borders, or by using the built-in Format Cells dialog on the Home tab. A macro is usually the best method if you need to repeat this action frequently across many workbooks or sheets. You need to have a basic understanding of the Excel interface, specifically how to open the Visual Basic Editor, and you should have a clear idea of which cells, rows, or columns you want to modify.

What You'll Need

  • A computer running Microsoft Excel (2016, 2019, or Microsoft 365 are recommended).
  • A spreadsheet with data that currently has borders applied to it.
  • The ability to open the Visual Basic Editor (VBE).
  • Familiarity with basic VBA syntax, such as declaring variables and using the With statement.

Step-by-Step

  1. Select the data range. Click and drag your mouse over the cells, rows, or columns from which you want to remove all borders. If you want to remove borders from the entire active sheet, you can press Ctrl + A to select all cells.
  2. Open the Visual Basic Editor. Press Alt + F11 on your keyboard. This is the standard shortcut to open the VBE in Windows. Alternatively, you can go to the Developer tab on the ribbon and click the Visual Basic button.
  3. Insert a new module. In the VBE window, look for the Project Explorer pane on the left side. If you don't see it, you can press Ctrl + R to toggle it on. Right-click on the project name for your workbook and select Insert > Module. This creates a blank white window where you will write your code.
  4. Enter the VBA code. In the new module window, paste the following code. This script uses the Range object and the Borders property to clear all formatting for the selected range. It also includes a check to ensure the range is valid before it tries to run.
    Sub RemoveBordersFromSelection()
        Dim rng As Range
        On Error Resume Next
        Set rng = Selection
        On Error GoTo 0
        
        If rng Is Nothing Then
            MsgBox "Please select a range of cells first."
            Exit Sub
        End If
        
        With rng.Borders
            .LineStyle = xlNone
            .Weight = xlThin
            .ColorIndex = xlAutomatic
        End With
        
        MsgBox "Borders have been removed from the selected range.", vbInformation
    End Sub
  5. Run the macro. You have a few ways to do this. The most direct way is to simply click anywhere inside the code you just pasted and press F5 on your keyboard. This will execute the code with the currently selected range. Alternatively, you can close the VBE and return to your Excel sheet. Go to the Developer tab and click Macros. In the list, select RemoveBordersFromSelection and click Run.
  6. Verify the result. Check your spreadsheet. The borders should be gone from the cells you selected. The text inside the cells should now be visible against the white background of the sheet.
  7. Save your workbook. If you want to keep this macro available for future use, save your workbook as an Excel Macro-Enabled Workbook (.xlsm). If you save it as a standard .xlsx file, the macro will be lost.

Alternative Method: Using the Format Cells Dialog

  1. Select the range. Highlight the cells, rows, or columns you want to modify.
  2. Open the dialog. Right-click on the selected cells and choose Format Cells from the context menu. Alternatively, go to the Home tab on the ribbon, find the Font group, and click the small arrow in the bottom-right corner of that group.
  3. Navigate to the Border tab. In the Format Cells dialog box, click on the Border tab at the top of the window.
  4. Remove existing borders. You will see a preview of the current border style in the center of the dialog. Look at the Line section on the right and select None from the Style list. Then, click the buttons in the Border section to clear the top, bottom, left, and right borders. You can also click the diagonals if they are present. Once all the buttons in the Border section are grayed out (no line style is selected), the borders will be removed.
  5. Apply and close. Click OK to apply the changes and close the dialog box.

Common Mistakes

  • Not selecting a range first. If you try to run the VBA macro without first clicking on some cells, the code will trigger the error message "Please select a range of cells first." Always make sure your selection is active before running the script.
  • Using the wrong line style. A common mistake is setting the LineStyle to xlContinuous or another specific style instead of xlNone. Setting it to xlNone is the only way to completely remove the visual border. Setting it to a style will just change the look of the existing border.
  • Forgetting to save as .xlsm. If you write a useful macro and save the file as a standard .xlsx, Excel will remove the macro code when it saves. The borders will be there, but the script will be gone. Always use the Macro-Enabled format for files containing custom code.
  • Applying the change to the whole sheet when only a range was needed. If you select a single cell and run the macro, it will only clear the borders of that single cell. If you want to clear borders for a large dataset, make sure you drag your mouse to select the entire block of data before running the code.

Tips

  • Use the With statement. The code provided in the VBA section uses the With rng.Borders structure. This is a best practice in VBA. It tells the program to focus on the rng.Borders object for a series of actions. It makes the code easier to read and reduces the chance of errors. Without it, you would have to write rng.Borders.LineStyle = xlNone and rng.Borders.Weight = xlThin on separate lines.
  • Combine with other formatting. You can add other lines of code inside the With block to clear other formats at the same time. For example, you could add .Interior.ColorIndex = xlNone to remove the background color, or .Font.Bold = False to remove bold formatting.
  • Check for errors. The line On Error Resume Next in the VBA code is a safety feature. It tells the program to ignore any errors that might occur if the range is not found. The code then checks if the rng variable is still Nothing and asks you to select a range if it is. This prevents the program from crashing and giving you a cryptic error message.
  • Use a button. For a more user-friendly experience, you can add a button to your toolbar that runs this macro. Right-click on the ribbon and choose Customize the Ribbon. In the right-hand pane, select Macros from the list of commands. Find your RemoveBordersFromSelection macro and click Add. You can then move it to any group on the ribbon and rename it to something like "Clear Borders".

Troubleshooting

If the borders do not disappear after running the macro, the first thing to check is whether the selection was made correctly. The macro is designed to work on the Selection object. If you have a complex selection, such as non-contiguous cells (cells that are not next to each other), the macro may not behave as expected. Try to make a simple, contiguous block of cells your selection.

Another possibility is that the cells are protected. If the worksheet is protected with a password, you cannot modify the borders of the cells. Go to the Review tab and click Unprotect Sheet. Enter the password if prompted, run the macro again, and then reprotect the sheet if necessary.

If the macro runs without error but the borders remain, it is possible that the cells have a conditional formatting rule that is applying a border. Conditional formatting can be more powerful than standard formatting. To check for this, select your range and go to the Home tab. Look for the Conditional Formatting button and choose Clear Rules > Clear Rules from Selected Cells. This will remove any conditional formatting rules that might be the source of the borders.

Frequently Asked Questions

How do I remove only the bottom border?

You can modify the VBA code to target specific sides of the border. Instead of clearing all borders, you would set the .LineStyle to xlNone for only the bottom border. In the Format Cells dialog, you would select a line style in the Line section and then click the bottom border button in the Border section. This will apply that line style only to the bottom edge.

Can I use this macro to remove borders from every sheet in a workbook?

Yes, you can write a loop to iterate through all sheets in the workbook. You would use a For Each loop to go through the ThisWorkbook.Sheets collection and apply the RemoveBordersFromSelection logic to each sheet. However, be careful not to remove borders from sheets that you want to keep.

What is the difference between xlNone and xlContinuous?

xlNone is the constant that tells Excel to remove a border. It effectively tells the program, "There is no border here." xlContinuous is a constant that tells Excel to draw a solid, continuous line. It is used to create a border, not to remove one.

Why does my macro run but nothing happens?

If the macro runs without error but no borders are removed, it is likely because the Selection object is empty or invalid. The macro includes an error handler to check for this, but if the error handling is not working correctly, the macro might simply skip the With block. Double-check that you have actually clicked on some cells before running the macro.

Is there a shortcut to remove borders?

There is no built-in keyboard shortcut to remove borders in Excel. You have to go through the menus or use a macro. You can, however, set up a custom keyboard shortcut for your macro in the Customize Ribbon dialog, which will give you a quick way to run the code.