How to Create a Custom Multi-Segment Border in Excel
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.

- 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.
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.
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.
Navigate to the Insert tab on the Excel ribbon, click on Illustrations, and select Shapes. Choose the simple Line shape.
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.
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.
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 Adjacent Narrow Cells to Mimic Segments
If you prefer avoiding floating shapes, you can create the illusion of multi-segment borders by resizing adjacent rows and columns and applying standard borders to them.
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. Download WPS Office: Visit the official WPS website to download and install the free WPS Office suite.
- 2. Open Your Spreadsheet: Launch WPS Spreadsheets and open your existing .xlsx file without losing any formatting or data.
- 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.

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.




