ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Problem with simple routine to change font size (https://www.excelbanter.com/excel-programming/382624-problem-simple-routine-change-font-size.html)

suzie

Problem with simple routine to change font size
 
Hi,

Could anyone help me. I'm struggling with the following two routines that
allow the user to change the font size.

Sub fontsize(size As Byte)
ActiveCell.Font.size = size
End Sub

Sub test()
a = InputBox("please enter fontsize")
Call fontsize(a)
End Sub

It gives me an error but I think it should work. Is this a bug?

Thanks

Suzie

Dave Peterson

Problem with simple routine to change font size
 
I think I would have use Double.

Option Explicit
Sub fontsize(size As Double)
ActiveCell.Font.size = size
End Sub
Sub test()
Dim a As Double
a = InputBox("please enter fontsize")
Call fontsize(a)
End Sub

But your code worked ok in my simple tests.

What did you specify as a font size?

What happened when you tried it? What was the error?



Suzie wrote:

Hi,

Could anyone help me. I'm struggling with the following two routines that
allow the user to change the font size.

Sub fontsize(size As Byte)
ActiveCell.Font.size = size
End Sub

Sub test()
a = InputBox("please enter fontsize")
Call fontsize(a)
End Sub

It gives me an error but I think it should work. Is this a bug?

Thanks

Suzie


--

Dave Peterson

suzie

Problem with simple routine to change font size
 
That works great, thanks very much

Suzie

"Dave Peterson" wrote:

I think I would have use Double.

Option Explicit
Sub fontsize(size As Double)
ActiveCell.Font.size = size
End Sub
Sub test()
Dim a As Double
a = InputBox("please enter fontsize")
Call fontsize(a)
End Sub

But your code worked ok in my simple tests.

What did you specify as a font size?

What happened when you tried it? What was the error?



Suzie wrote:

Hi,

Could anyone help me. I'm struggling with the following two routines that
allow the user to change the font size.

Sub fontsize(size As Byte)
ActiveCell.Font.size = size
End Sub

Sub test()
a = InputBox("please enter fontsize")
Call fontsize(a)
End Sub

It gives me an error but I think it should work. Is this a bug?

Thanks

Suzie


--

Dave Peterson



All times are GMT +1. The time now is 12:07 PM.

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