ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   how to trigger macro or force autofit (https://www.excelbanter.com/excel-programming/280782-how-trigger-macro-force-autofit.html)

lcoreyl

how to trigger macro or force autofit
 
Is it possible to trigger a macro by changing a particular cell?

More specifically, I am running a cell height format macro, and it
would be nice if it would automatically run whenever a cell change was
made.

another solution would be if anyone knows how to make row height
autofit work on merged cells. I don't understand why it doesn't...



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/


lcoreyl[_2_]

how to trigger macro or force autofit
 
sorry, found another thread already dealing with this...

http://www.excelforum.com/showthread...hreadid=156446



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/


J.E. McGimpsey

how to trigger macro or force autofit
 
Take a look at the worksheet_Change event macro:

http://cpearson.com/excel/events.htm

One way:

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Target.Rows.AutoFit
End Sub

If you have merged cells, take a look he

http://google.com/groups?selm=053101...001280a%40p h
x.gbl



In article ,
lcoreyl wrote:

Is it possible to trigger a macro by changing a particular cell?

More specifically, I am running a cell height format macro, and it
would be nice if it would automatically run whenever a cell change was
made.

another solution would be if anyone knows how to make row height
autofit work on merged cells. I don't understand why it doesn't...


Tom Ogilvy

how to trigger macro or force autofit
 
Use the change event to run your macro.

Right click on the worksheet tab and select view code.

in the left dropdown select Worksheet and in the Right, Change, (not
SelectionChange). This will put in the declaration for the change event and
you can call you macro here. The target arguments specify the Cell or
cells that were edited and triggered the event.

--
Regards,
Tom Ogilvy

"lcoreyl" wrote in message
...
Is it possible to trigger a macro by changing a particular cell?

More specifically, I am running a cell height format macro, and it
would be nice if it would automatically run whenever a cell change was
made.

another solution would be if anyone knows how to make row height
autofit work on merged cells. I don't understand why it doesn't...



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/





All times are GMT +1. The time now is 10:29 PM.

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