View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
dennis dennis is offline
external usenet poster
 
Posts: 202
Default Format changed when the cell selected

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Application.ActiveCell = Application.Range("C9") Then
Application.ActiveCell.Font.Size = 12
Application.ActiveCell.Font.Bold = True
Application.ActiveCell.Interior.ColorIndex = 3
Application.ActiveCell.Font.ColorIndex = 2
Else
Application.Range("C9").Font.Size = 10
Application.Range("C9").Font.Bold = False
Application.Range("C9").Interior.ColorIndex = 2
Application.Range("C9").Font.ColorIndex = 1
End If
End Sub

"Freshman" wrote:

Hi Dennis,

Thanks for your code and it works perfect. However, I'm sorry that I did not
ask my question clearly. I want to changed format can be restore to original
format if the cell is deselected afterwards. What additional codes should be
added? Please kindly advise. Sorry for trouble you on this.

Best regards.

"Dennis" wrote:

Enter this into the visual basic editor for your worksheet. In my example
cell C9 is the one that changes when it is activated.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Application.ActiveCell = Application.Range("C9") Then
Application.ActiveCell.Font.Size = 12
Application.ActiveCell.Font.Bold = True
Application.ActiveCell.Interior.ColorIndex = 3
Application.ActiveCell.Font.ColorIndex = 2
End If
End Sub

"Freshman" wrote:

Dear experts,

I want when a cell is selected, the font of a value inside this cell will be
enlarged from point 10 to pont 12, the font colour will be changed from black
to bold white and the background colour will be changed to red. Can it be
done by a VBA code or any other ways? Please kindly advise.

Thanks in advance.