Miercuri, 06 octombrie 2021
  3 Răspunsuri
  7.2K vizite
0
Voturi
Anula
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....?

Sper sa ne mai auzim

Cel mai bune
Marianne
de ani în urmă 2
·
#2314
0
Voturi
Anula
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


Dacă aveți alte întrebări, vă rugăm să nu ezitați să-mi spuneți.

Amanda
de ani în urmă 2
·
#2315
0
Voturi
Anula
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
Atasamente (1)
de ani în urmă 2
·
#2316
0
Voturi
Anula
Thanks, the issue has been resolved in another way in the meantime.
  • Pagina:
  • 1
Nu există răspunsuri făcute pentru acest post.