cancel
Showing results for 
Search instead for 
Did you mean: 

Trigger a macro when a new characteristic is inserted in columns

N1kh1l
Active Contributor
0 Kudos

Hello All,

I am trying to look for an event to call a macro when a user inserts /removes new characteristics in columns in AFO workbook. I have tried counting number of columns in a cell and try to use the worksheet_calculate event on cell change due to formula but it doesn't seem to work. I have also tried the API call back Callback_AfterRedisplay() but this too is not helping much. Is there any event that can be used.

Thanks in advance

Nikhil

View Entire Topic
yogananda
Product and Topic Expert
Product and Topic Expert
0 Kudos

nikhil_1486
Unfortunately, there is no built-in event for when a user inserts or removes columns in an AFO workbook. You will need to create your own custom solution to detect and respond to changes in the columns.
One approach you could use is to track changes in the column count using the workbook_calculate event. You can compare the column count before and after the event to determine if any columns were added or removed.
Another approach would be to use the API callback Callback_AfterRedisplay() to detect changes in the column count. This API callback will be triggered whenever the AFO window is refreshed, which should occur when columns are added or removed. You can then compare the column count before and after the callback to determine if any columns were added or removed.

N1kh1l
Active Contributor
0 Kudos

yoganandamuthaiah

I exactly tried the approaches you suggest but for some reason it does not work. I used an excel formula COUNTA() to get the count of columns in a cell and then used worksheet_calculate () event of the worksheet on this cell to check old and new value of the cell to trigger the macro. If I manually change the value in this cell it works but not when the cell value changes due to formula. I even tried the Callback_AfterRedisplay() to get a trigger but this will fire only when a refresh is done but i want to get my macro before refresh.

Nikhil