Font size and color change for selected cell only

S

Shazi

I have the following procedure to view the selected cell bigger size,
when I move my cursor I need Font to be changed from 10 size to 18
size.
I made the below procedure.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Application.ScreenUpdating = False

Cells.Interior.ColorIndex = xlNone
Target.Interior.ColorIndex = 8

With Selection.Font
.Name = "Arial"
.Size = 18
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With

Application.ScreenUpdating = True

End Sub


The problem is this when I move the curssor it Increase the size of
Font from 10 to 18, and It should be 10 size when I move to next
cell...

I hope you understand what I mean.

Pls send me reply, how it will be possible.

Regards.

Shahzad Zafar
Madinah
 
G

Gary''s Student

Add a single line:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Application.ScreenUpdating = False

Cells.Interior.ColorIndex = xlNone
Cells.Font.Size = 10
Target.Interior.ColorIndex = 8

With Selection.Font
.Name = "Arial"
.Size = 18
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With

Application.ScreenUpdating = True

End Sub
 
T

Tom Ogilvy

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Application.ScreenUpdating = False

Cells.Interior.ColorIndex = xlNone


With Cells.Font
.Name = "Arial"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With

Target.Interior.ColorIndex = 8
With Target.Font
.Name = "Arial"
.Size = 18
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With

Application.ScreenUpdating = True

End Sub
 
D

Don Guillett

Try this instead, including the line public lastcell
'==============
Public lastcell
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

With Range(lastcell)
.Interior.ColorIndex = xlNone
.Font.Size = 10
End With

With Target
.Font.Size = 18
.Interior.ColorIndex = 8
End With

lastcell = Target.Address
End Sub

'==========
 
D

Don Guillett

You may want to add
on error resume next
as the FIRST line WITHIN the macro
 
S

Shazi

You may want to add
on error resume next
as the FIRST line WITHIN the macro

--
Don Guillett
Microsoft MVP Excel
SalesAid Software









- Show quoted text -

Dear All,

Thank you very much for your support, you solved my big problem which
I was facing on daily routine. Now I am able to view any thing larger
when I click on any cell.

Once again thank you for all,


with best personal regards.

Syed Shahzad Zafar
Madinah
 

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

Similar Threads


Top