Note: The other languages of the website are Google-translated. Back to English
Log in  \/ 
x
or
x
Register  \/ 
x

or
×

file Option "Copy only borders"

More
1 month 3 weeks ago - 1 month 3 weeks ago #3962 by Amanda Lee
Replied by Amanda Lee on topic Option "Copy only borders"
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 Cell 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
Last edit: 1 month 3 weeks ago by Amanda Lee.

Please Log in or Create an account to join the conversation.

More
3 months 3 weeks ago #3810 by MariannevanLubek
Option "Copy only borders" was created by MariannevanLubek
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:
How to copy only borders of selected range in Excel? 

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

Please Log in or Create an account to join the conversation.

Moderators: ExcelfansOfficeFansAmanda Lee