Note: The other languages of the website are Google-translated. Back to English
  Wednesday, 06 October 2021
  3 Replies
  3.6K Visits
0
Votes
Undo
I just purchased the Kutools for Excel because I was looking for an option to copy in Excel only the borders from a selected area - leaving the content, formatting, column width from the destination area unchanged.

I found a solution for this - using Kutools for Excel on this web-page:
https://www.extendoffice.com/documents/excel/4336-excel-copy-borders-only.html#a1 

Now I tried to use the suggested macro and discovered it doesn't do at all what was promised:
Besides copying the borders it also:
- deletes the formatting from the destionation area
- changes the column of the destionation area
Moreover the macro works quite slow and the changes can't be undone.

Could you please help me out to ensure that the macro does what was promised....?

Hope to hear from you

Best
Marianne
1 year ago
·
#2314
0
Votes
Undo
Hi MariannevanLubek,

Sorry for the trouble. Here we have written another macro for the case. Can you please try?

Sub CopyBorders()
Dim xRg, yRg As Range
On Error Resume Next

Set xRg = Application.InputBox("Select Range with Borders to Copy...", "Kutools For Excel", , , , , , 8)
Set yRg = Application.InputBox("Select Cells to Apply Borders to range..", "Kutools For Excel", , , , , , 8)

With yRg.Borders(xlEdgeLeft)
.LineStyle = xRg.Borders(xlEdgeLeft).LineStyle
.ColorIndex = xRg.Borders(xlEdgeLeft).ColorIndex
.TintAndShade = xRg.Borders(xlEdgeLeft).TintAndShade
.Weight = xRg.Borders(xlEdgeLeft).Weight
End With
With yRg.Borders(xlEdgeTop)
.LineStyle = xRg.Borders(xlEdgeTop).LineStyle
.ColorIndex = xRg.Borders(xlEdgeTop).ColorIndex
.TintAndShade = xRg.Borders(xlEdgeTop).TintAndShade
.Weight = xRg.Borders(xlEdgeTop).Weight
End With
With yRg.Borders(xlEdgeBottom)
.LineStyle = xRg.Borders(xlEdgeBottom).LineStyle
.ColorIndex = xRg.Borders(xlEdgeBottom).ColorIndex
.TintAndShade = xRg.Borders(xlEdgeBottom).TintAndShade
.Weight = xRg.Borders(xlEdgeBottom).Weight
End With
With yRg.Borders(xlEdgeRight)
.LineStyle = xRg.Borders(xlEdgeRight).LineStyle
.ColorIndex = xRg.Borders(xlEdgeRight).ColorIndex
.TintAndShade = xRg.Borders(xlEdgeRight).TintAndShade
.Weight = xRg.Borders(xlEdgeRight).Weight
End With
With yRg.Borders(xlInsideHorizontal)
.LineStyle = xRg.Borders(xlInsideHorizontal).LineStyle
.ColorIndex = xRg.Borders(xlInsideHorizontal).ColorIndex
.TintAndShade = xRg.Borders(xlInsideHorizontal).TintAndShade
.Weight = xRg.Borders(xlInsideHorizontal).Weight
End With
With yRg.Borders(xlInsideVertical)
.LineStyle = xRg.Borders(xlInsideVertical).LineStyle
.ColorIndex = xRg.Borders(xlInsideVertical).ColorIndex
.TintAndShade = xRg.Borders(xlInsideVertical).TintAndShade
.Weight = xRg.Borders(xlInsideVertical).Weight
End With
End Sub


If you have any other questions, please don't hesitate to let me know.

Amanda
9 months ago
·
#2315
0
Votes
Undo
Hi MariannevanLubek,

One thing I have to tell you is that, after you run the code, you have to select all the cells where you want to apply the borders but not one cell, just like the screenshot below:
select cells.png

Amanda
Attachments (1)
9 months ago
·
#2316
0
Votes
Undo
Thanks, the issue has been resolved in another way in the meantime.
  • Page :
  • 1
There are no replies made for this post yet.

Follow Us

Copyright © 2009 - www.extendoffice.com. | All rights reserved. Powered by ExtendOffice. | Sitemap
Microsoft and the Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries.
Protected by Sectigo SSL