VBA set thick borders around non empty cells in range


Joined
Jun 8, 2021
Messages
1
Reaction score
0
Hello all, I am trying to make macro which would enclose all non empty cells within range with thick black borderline. I really tried to make something functional and similiar to the repeating section content control (RSCC) in Word, but i guess its imposible for me. The range is C19:J28. I have 3 columns consisted of merged cells, first 2 columns consist of 3 cells, the last one from 2 (main problem is, the code below is enclosing always only the first left one cell from the merged unit).
I hope I have explained my problem enough and i will appreciate any advice.


Code:

Sub Border()

Dim iRange As Range
Dim iCells As Range

Set iRange = Range("C19:J28")

For Each iCells In iRange
If Not IsEmpty(iCells) Then
iCells.BorderAround _
LineStyle:=xlContinuous, _
Weight:=xlThick
End If

Next iCells

End Sub

Sincerely, Morty
 
Last edited:
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top