Font enlarge/reduce by 1 pt?

  • Thread starter Thread starter StargateFanFromWork
  • Start date Start date
S

StargateFanFromWork

Is there syntax for reducing and enlarging font by 1 pt? What I mean by
that is so that if font in cell is 10pt, by clicking enlarge font by 1 pt,
it would increase to 11pt, and it we clicked again it would go to 12pt?

And the opposite, syntax to do "-1" point?

Thanks. :oD
 
You can use code like the following:

Sub ChangeFontSize()

Dim Res As VbMsgBoxResult
Dim R As Range
Dim N As Long

Res = MsgBox("Do you want to increase the size of the font?" & vbCrLf & _
"Click 'Yes' to enlarge the size of the font by one point." & vbCrLf & _
"Click 'No' to reduce the size of the font by one point." & vbCrLf & _
"Click 'Cancel' to terminate the operation.", vbYesNoCancel)

Select Case Res
Case vbYes
N = 1
Case vbNo
N = -1
Case Else
Exit Sub
End Select

If TypeOf Selection Is Excel.Range Then
For Each R In Selection.Cells
With R.Font
.Size = .Size + N
End With
Next R
End If

End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consulting
www.cpearson.com
(email on the web site)
 
Sub bumpit()
For Each r In Selection
r.Font.Size = r.Font.Size + 1
Next
End Sub

you can do something similar to make a shrinkit, but be usre to check for
not less than one.
 
selection.cells.font.size = selection.cells.font.size + 1
or -1 for reducing the font size.

HTH
Kalpesh
 
Kalpesh said:
selection.cells.font.size = selection.cells.font.size + 1
or -1 for reducing the font size.

HTH
Kalpesh

Thanks! This worked on individual cells. I checked the syntax I had that
worked on any selection and was able to modify slightly to something that
would work on one cell or many by removing "cells." to this:



INCREASING (+1 pt):
******************************************************************************
Sub FontSizeINCREASEonePoint()
ActiveSheet.Unprotect 'place at the beginning of the code
Selection.Font.Size = Selection.Font.Size + 1
ActiveSheet.Protect ' place at end of code
End Sub

******************************************************************************




DECREASING (-1 pt):
******************************************************************************
Sub FontSizeDECREASEonePoint()
ActiveSheet.Unprotect 'place at the beginning of the code
Selection.Font.Size = Selection.Font.Size - 1
ActiveSheet.Protect ' place at end of code
End Sub
******************************************************************************


I used for the icons in a floating toolbar, faceid's #39 and 40 (up and down
blue arrows).

Thanks! Always so easy once you know how <g>. :oD
 

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