ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Shouldnt this work? (https://www.excelbanter.com/excel-programming/363525-re-shouldnt-work.html)

Willot[_2_]

Shouldnt this work?
 

If I have a sheet Formula =IF(A1 < "",ChangeSize())

and the ChangeSize() Sub in a VBA module is

Sub ChangeSize()
Msgbox(ActiveCell.value)
ActiveCell.Font.Size = 15
End Sub

It Puts up the Msgbox with the value of A1
But it doesnt change font size in the cell???


--
Willot
------------------------------------------------------------------------
Willot's Profile: http://www.excelforum.com/member.php...o&userid=35166
View this thread: http://www.excelforum.com/showthread...hreadid=549356


Dave Peterson

Shouldnt this work?
 
Functions like these can't change the font.

With a couple of minor exceptions (like message boxes), they can only return
values to the cell that contains the function.


Willot wrote:

If I have a sheet Formula =IF(A1 < "",ChangeSize())

and the ChangeSize() Sub in a VBA module is

Sub ChangeSize()
Msgbox(ActiveCell.value)
ActiveCell.Font.Size = 15
End Sub

It Puts up the Msgbox with the value of A1
But it doesnt change font size in the cell???

--
Willot
------------------------------------------------------------------------
Willot's Profile: http://www.excelforum.com/member.php...o&userid=35166
View this thread: http://www.excelforum.com/showthread...hreadid=549356


--

Dave Peterson

Mat P:son[_2_]

Shouldnt this work?
 
And it would have been nice if Conditional Formatting supported font size
changes, but unfortunately it doesn't... (I guess that that is the reason you
tried to run a macro in the first place, right...?)

But you can of course run your macro as part of an event handler, e.g.,
Worksheet_Calculate() or Worksheet_Change(), which will then update your cell
format whenever your criterion has been met.

You can get hold of some example code he

http://exceltips.vitalnews.com/Pages...ionally.ht ml

Cheers,
/MP

"Dave Peterson" wrote:

Functions like these can't change the font.

With a couple of minor exceptions (like message boxes), they can only return
values to the cell that contains the function.


Willot wrote:

If I have a sheet Formula =IF(A1 < "",ChangeSize())

and the ChangeSize() Sub in a VBA module is

Sub ChangeSize()
Msgbox(ActiveCell.value)
ActiveCell.Font.Size = 15
End Sub

It Puts up the Msgbox with the value of A1
But it doesnt change font size in the cell???

--
Willot
------------------------------------------------------------------------
Willot's Profile: http://www.excelforum.com/member.php...o&userid=35166
View this thread: http://www.excelforum.com/showthread...hreadid=549356


--

Dave Peterson


Tom Ogilvy

Shouldnt this work?
 
Functions used in a worksheet and only return a value to the cell in which
they are used. They can not alter the excel environment. There are a few
exceptions, but nothing along the lines of what you want to do.

So no, it shouldn't work.

--
Regards,
Tom Ogilvy


"Willot" wrote:


If I have a sheet Formula =IF(A1 < "",ChangeSize())

and the ChangeSize() Sub in a VBA module is

Sub ChangeSize()
Msgbox(ActiveCell.value)
ActiveCell.Font.Size = 15
End Sub

It Puts up the Msgbox with the value of A1
But it doesnt change font size in the cell???


--
Willot
------------------------------------------------------------------------
Willot's Profile: http://www.excelforum.com/member.php...o&userid=35166
View this thread: http://www.excelforum.com/showthread...hreadid=549356




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

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