logo
search
Formatting Issues

How to Create a Custom Multi-Segment Border in Excel

John WilsonJohn Wilson Oct 9, 2026 869 views

Question details

The user wants to create a custom cell border with separate dashed segments on the left and right sides using VBA, rather than relying on standard presets.

How to Create a Custom Multi-Segment Border in Excel
Product
Excel 365
Device & OS
not provided
Scenario
Applying advanced custom formatting to specific cells where built-in border styles do not meet the visual requirements.
Observed behavior
Excel does not natively support true custom multi-segment border styles for a single cell, even through VBA. Border options are strictly limited to built-in presets.
Before you start

Because Excel limits cell borders to predefined styles, you cannot create a completely new multi-segment border style directly. Be prepared to use creative visual workarounds like drawing shapes or structuring adjacent cells to achieve your exact desired layout.

Solution 1Recommended

Use Line Shapes to Draw Custom Borders

Since Excel's native border tool lacks multi-segment customization, manually drawing and formatting line shapes over cell boundaries is the most effective way to create this specific visual.

By using Excel's shape tools, you bypass cell format limitations. You can draw separate segments (like a dashed line on the top left and a solid line on the bottom right) exactly where you need them.

To ensure shapes stay aligned with the cells if columns or rows are resized, you will need to adjust the shape's property settings.

1
Access the Shapes Menu

Navigate to the Insert tab on the Excel ribbon, click on Illustrations, and select Shapes. Choose the simple Line shape.

2
Draw and Snap to Grid

Hold down the Alt key on your keyboard while drawing the line along the edge of your target cell. The Alt key forces the shape to snap perfectly to the cell gridlines.

3
Format the Segments

Click on the drawn line, go to the Shape Format tab, and use Shape Outline to change the color, weight, and dashes to match your multi-segment requirement. Repeat for other sides of the cell.

4
Lock Shapes to Cells

Right-click the line shapes and select Format Shape. Under Size & Properties, choose 'Move and size with cells' so the custom borders adjust if you resize the spreadsheet.

Use Line Shapes to Draw Custom Borders
Visual Accuracy: Using line shapes guarantees you can mix and match any color, thickness, and dash type on a single cell boundary seamlessly.
Free Microsoft Office alternative

Design Better Spreadsheets with WPS Office

If Excel's formatting limitations are slowing you down, consider switching to WPS Office. It provides a lightweight, flexible environment for managing spreadsheets, complete with robust shape tools that make implementing visual workarounds incredibly easy.

  1. 1. Download WPS Office: Visit the official WPS website to download and install the free WPS Office suite.
  2. 2. Open Your Spreadsheet: Launch WPS Spreadsheets and open your existing .xlsx file without losing any formatting or data.
  3. 3. Apply Custom Shapes: Go to the Insert tab, select Shapes, and easily draw multi-segment dashed lines over your cells with enhanced snapping tools.
Completely free and lightweight office suiteSeamless format compatibility with Microsoft Excel (.xlsx)Intuitive UI with zero learning curve for Excel usersRobust built-in illustration tools for complex formatting tasks
microsoft office alternative - wps office

Frequently Asked Questions

Can I use VBA to invent a completely new cell border style?

No, Excel's object model and VBA can only apply the standard border enumerations (e.g., xlContinuous, xlDash, xlDot). It cannot generate a completely customized multi-segment border that is not already built into the software.

Will line shapes used as custom borders print correctly?

Yes, line shapes will print just like normal cell borders as long as you have 'Print object' enabled. You can verify this by right-clicking the shape, selecting Format Shape > Properties, and ensuring 'Print object' is checked.

How do I make multiple line shapes act as one border?

You can group multiple line shapes together so they behave as a single element. Select all your custom line shapes by holding Ctrl and clicking them, then right-click and select Group > Group.

Are there third-party add-ins for multi-segment borders?

While some formatting add-ins exist, none can bypass the fundamental cell rendering limitations of Excel natively. Add-ins typically automate the shape-drawing workaround rather than altering the native cell border properties.