ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How do I program in VBA some Excel behaviours like colored-cell-. (https://www.excelbanter.com/excel-programming/319301-how-do-i-program-vba-some-excel-behaviours-like-colored-cell.html)

TEXNAC

How do I program in VBA some Excel behaviours like colored-cell-.
 
How do I program in VBA some Excel behaviours like colored-cell-borders
after pressing F2?

Lonnie M.

How do I program in VBA some Excel behaviours like colored-cell-.
 
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.


Nick Shinkins[_2_]

How do I program in VBA some Excel behaviours like colored-cell-.
 
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?

"TEXNAC" wrote:

How do I program in VBA some Excel behaviours like colored-cell-borders
after pressing F2?



All times are GMT +1. The time now is 03:03 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com