Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default Enlarge font & change color when cell is selected

I need to make a range of cells increase their font size when
selected. I found the following macro:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Columns(1).Font.Size = 10
If Target.Column = 1 Then
Target.Font.Size = 15
End If
End Sub

This works great for a single column, but I need 10 columns. Also, if
I wanted a color when the cell is selected, how would these be
written? Thank you for your help.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Enlarge font & change color when cell is selected

You need the for loop in the code below if you are copying and pasting morre
than one cell

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
For Each cell In Target
If cell.Columns <= 10 Then
cell.Font.Size = 15
cell.Interior.ColorIndex = 5
Else
cell.Font.Size = 10
cell.Interior.ColorIndex = xlNone
End If
Next cell
End Sub


" wrote:

I need to make a range of cells increase their font size when
selected. I found the following macro:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Columns(1).Font.Size = 10
If Target.Column = 1 Then
Target.Font.Size = 15
End If
End Sub

This works great for a single column, but I need 10 columns. Also, if
I wanted a color when the cell is selected, how would these be
written? Thank you for your help.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 83
Default Enlarge font & change color when cell is selected

Hi Michael

If you want to change the font size and color only when you select, and
bring it back when the cell in not selected, then try the below


Dim LastFontSize As Long
Dim LastColorIndex As Long
Dim LastVisitedCell As String

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Application.ScreenUpdating = False
If Len(LastVisitedCell) 0 Then
Range(LastVisitedCell).Interior.ColorIndex = LastColorIndex
Range(LastVisitedCell).Font.Size = LastFontSize
End If
LastColorIndex = Target.Interior.ColorIndex
LastFontSize = Target.Font.Size
Target.Interior.ColorIndex = 8
With Selection.Font
.Name = "Arial"
.Size = 20
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
Application.ScreenUpdating = True
LastVisitedCell = Target.Address
End Sub



" wrote:

I need to make a range of cells increase their font size when
selected. I found the following macro:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Columns(1).Font.Size = 10
If Target.Column = 1 Then
Target.Font.Size = 15
End If
End Sub

This works great for a single column, but I need 10 columns. Also, if
I wanted a color when the cell is selected, how would these be
written? Thank you for your help.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default Enlarge font & change color when cell is selected

Thank you for your kind help. I will be trying out both suggestions
shortly. Thanks again.

Michael
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cannot change font color or cell color Bezell Excel Discussion (Misc queries) 2 January 30th 09 06:12 PM
Font size and color change for selected cell only Shazi Excel Programming 5 July 11th 08 11:10 PM
Reg. Change of font color in a cell Ravi Excel Worksheet Functions 1 June 27th 08 10:07 AM
Change font color in cell Peggy Excel Discussion (Misc queries) 2 June 24th 08 04:30 PM
How to change the default Border, Font Color, and Cell Color Elijah Excel Discussion (Misc queries) 3 November 2nd 05 11:52 PM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"