By มารีแอนน์วาน ลูเบค ในวันพุธที่ 06 ตุลาคม 2021
โพสต์ใน Kutools สำหรับ Excel
ตอบกลับ 3
การกดไลค์ 0
เข้าชม 7.2K
โหวต 0
ฉันเพิ่งซื้อ Kutools สำหรับ Excel เพราะฉันกำลังมองหาตัวเลือกในการคัดลอกใน Excel เฉพาะเส้นขอบจากพื้นที่ที่เลือก โดยปล่อยให้เนื้อหา การจัดรูปแบบ ความกว้างของคอลัมน์จากพื้นที่ปลายทางไม่เปลี่ยนแปลง

ฉันพบวิธีแก้ปัญหานี้โดยใช้ Kutools for Excel บนหน้าเว็บนี้:
https://www.extendoffice.com/documents/excel/4336-excel-copy-borders-only.html#a1 

ตอนนี้ฉันพยายามใช้มาโครที่แนะนำและพบว่าไม่เป็นไปตามที่สัญญาไว้:
นอกจากการคัดลอกเส้นขอบแล้ว มันยัง:
- ลบการจัดรูปแบบออกจากพื้นที่ปลายทาง
- เปลี่ยนคอลัมน์ของพื้นที่ปลายทาง
นอกจากนี้ มาโครยังทำงานค่อนข้างช้าและไม่สามารถยกเลิกการเปลี่ยนแปลงได้

โปรดช่วยฉันเพื่อให้แน่ใจว่ามาโครทำในสิ่งที่สัญญาไว้....?

หวังว่าจะได้ยินจากคุณ

ดีที่สุด
หญิง
สวัสดี MariannevanLubek

ขอโทษสำหรับปัญหา. ที่นี่เราได้เขียนมาโครอีกอันสำหรับเคสนี้ ลองหน่อยได้ไหม

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


หากคุณมีคำถามอื่นๆ โปรดแจ้งให้เราทราบ

อแมนดา
·
2 ปีที่ผ่านมา
·
0 ชอบ
·
0 คะแนน
·
0 คอมเมนต์
·
สวัสดี MariannevanLubek

สิ่งหนึ่งที่ฉันต้องบอกคุณคือ หลังจากที่คุณรันโค้ด คุณต้องเลือกเซลล์ทั้งหมดที่คุณต้องการใช้เส้นขอบ แต่ไม่ใช่เซลล์เดียว เช่นเดียวกับภาพหน้าจอด้านล่าง:
เลือกเซลล์.png


อแมนดา
·
2 ปีที่ผ่านมา
·
0 ชอบ
·
0 คะแนน
·
0 คอมเมนต์
·
ขอบคุณ ปัญหาได้รับการแก้ไขด้วยวิธีอื่นในระหว่างนี้
·
2 ปีที่ผ่านมา
·
0 ชอบ
·
0 คะแนน
·
0 คอมเมนต์
·
ดูโพสต์แบบเต็ม