ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Font enlarge/reduce by 1 pt? (https://www.excelbanter.com/excel-programming/403769-font-enlarge-reduce-1-pt.html)

StargateFanFromWork[_4_]

Font enlarge/reduce by 1 pt?
 
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



Chip Pearson

Font enlarge/reduce by 1 pt?
 
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)

"StargateFanFromWork" wrote in message
...
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



Gary''s Student

Font enlarge/reduce by 1 pt?
 
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.
--
Gary''s Student - gsnu200764


"StargateFanFromWork" wrote:

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




Kalpesh[_2_]

Font enlarge/reduce by 1 pt?
 
selection.cells.font.size = selection.cells.font.size + 1
or -1 for reducing the font size.

HTH
Kalpesh


All times are GMT +1. The time now is 10:12 AM.

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