Borders

K

Khalil Handal

Hello to all,
I have a range of cells C34:N35
I need VBA code in order to have borders for this range or clearing the
borders depending on the checkbox if it is cliked or not.
ie. The code will be part of CheckBox2 button with condition to show the
border or hide them.The sheet is protected.
 
G

Guest

Hi,

Record the code to turn on and off the borders and put it inside the
Checkbox_Click procedure.
 
K

Khalil Handal

NOT homework!
I was able to show / hide the numbers inside the range according to the
check box by changing the color to white and then black again. It didn't
look nice to have borders for empty cells! so the idea came to not see the
borders.
I recorded the macro and it has (i think) seven line which looks too long.

Thanks to both of you.
 
D

Don Guillett

You can adapt this to make the borders

Sub bordersaround()
Worksheets("Sheet1").Range("A1:D4").BorderAround _
ColorIndex:=3, Weight:=xlThick
'Selection.bordersaround
End Sub

or this to erase them

Sub noborders()
Worksheets("Sheet1").Range("A1:D4") _
.Borders.LineStyle = xlNone
End Sub
 
K

Khalil Handal

Thanks!
I was always interestred in spliting the line in VB code which is seen as _
..
What key combination does this?????
 
G

Gord Dibben

That is the underscore character. SHIFT + - (hyphen)

Make sure you have a <space> between last character and the underscore _


Gord Dibben MS Excel MVP
 
K

Khalil Handal

Thanks

Gord Dibben said:
That is the underscore character. SHIFT + - (hyphen)

Make sure you have a <space> between last character and the underscore _


Gord Dibben MS Excel MVP
 

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