Pembahasan kali ini adalah cara membuat Border Otomatis sesuai data cell dengan demikian border akan menambah otomatis bila data cell ditambah
Cara cukup Mudah Pastekan kode berikut pada sheet yang akan
menjadi target sebagai Private Sub Worksheet_Change
Kode lengkapnya :
Private Sub Worksheet_Change(ByVal Target As Range)
Dim LastRow As Long, LastCol As Long
Cells.Borders.LineStyle = xlNone
LastRow = Cells.Find("*", , xlValues, , xlRows, xlPrevious).Row
LastCol = Cells.Find("*", , xlValues, , xlByColumns, xlPrevious).Column
With Range("A5", Cells(LastRow, LastCol))
.BorderAround xlDouble
.Rows.Borders(xlInsideHorizontal).LineStyle = xlDash
.Rows.Borders(xlInsideVertical).LineStyle = xlContinuous
End With
End Sub
Kode lengkapnya :
Private Sub Worksheet_Change(ByVal Target As Range)
Dim LastRow As Long, LastCol As Long
Cells.Borders.LineStyle = xlNone
LastRow = Cells.Find("*", , xlValues, , xlRows, xlPrevious).Row
LastCol = Cells.Find("*", , xlValues, , xlByColumns, xlPrevious).Column
With Range("A5", Cells(LastRow, LastCol))
.BorderAround xlDouble
.Rows.Borders(xlInsideHorizontal).LineStyle = xlDash
.Rows.Borders(xlInsideVertical).LineStyle = xlContinuous
End With
End Sub
Selesai
Semoga bermanfaat
Silahkan klik halaman Download dibawah ini
No comments:
Post a Comment