สวัสดีครับอาจารย์
อ่า...อันนี้ต้องให้อาจารย์ช่วยครับ
Private Sub Report()
Dim ri As Range
On Error Resume Next
With Workbooks("DumP.xlsm").Worksheets("Report")
Set ri = .Range(.Range("A1"), .Range("I65536") _
.End(xlUp)).SpecialCells(xlCellTypeVisible)
End With
ri.Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
ri.PrintOut
End Sub
อาจารย์ครับมีสั้นและกระชับกว่านี้ไหมครับ เพื่อกำหนดให้ ri มีเส้นตาราง ขอจริงๆครับ
ประเด็นที่ 2 Worksheets("Report") เป็นชีทที่รับค่าข้อมูล ซึ่งข้อมูลมีลักษณะต่างกันตามข้อมูลที่ผู้ใช้เรียก
ความต้องการคือ หลังจาก
Private Sub Report()
Dim ri As Range
On Error Resume Next
With Workbooks("DumP.xlsm").Worksheets("Report")
Set ri = .Range(.Range("A1"), .Range("I65536") _
.End(xlUp)).SpecialCells(xlCellTypeVisible)
End With
ri.Select
จะกำหนดค่าอย่างไรให้ ช่วงความกว้างของ Columm ของช่วงข้อมูล ri มีความกว้างพอดีกับเนื้อหา
(เนื้อหาที่มากที่สุดของแต่ละคอลัมม์)
รบกวนด้วยนะครับ ช่วยด้วยนะครับ
