How do I program in VBA some Excel behaviours like colored-cell-.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How do I program in VBA some Excel behaviours like colored-cell-borders
after pressing F2?
 
HI,
Place the following code in 'ThisWorkbook':
'########################################################
Sub Auto_Open()
Application.OnKey "{F2}", "myBorders"
End Sub
'########################################################

Insert a module and place the following code:
'########################################################
Public Sub myBorders()
On Error Resume Next
With Selection.Borders(xlEdgeLeft)
..LineStyle = xlContinuous
..Weight = xlThin 'xlMedium xlThick xlHairline
..ColorIndex = 15
End With
With Selection.Borders(xlEdgeTop)
..LineStyle = xlContinuous
..Weight = xlThin 'xlMedium xlThick xlHairline
..ColorIndex = 15
End With
With Selection.Borders(xlEdgeBottom)
..LineStyle = xlContinuous
..Weight = xlThin 'xlMedium xlThick xlHairline
..ColorIndex = 15
End With
With Selection.Borders(xlEdgeRight)
..LineStyle = xlContinuous
..Weight = xlThin 'xlMedium xlThick xlHairline
..ColorIndex = 15
End With
End Sub
'########################################################
HTH--Lonnie M.
 
If you could explain more precisely what you would like to do then I may be
able to help.

Exactly which behaviours do you wish to emulate?
 

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

Back
Top