Trigger VBA on action 'increase indent'

msdejong79

New Member
Joined
Mar 28, 2016
Messages
10

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Maybe this?

Howard


Using this property to set the indent level to a number less than 0 (zero) or greater than 15 causes an error.

Code:
With Range("A10") 
 .IndentLevel = 15 
End With
 
Upvote 0
Maybe this?

Howard


Using this property to set the indent level to a number less than 0 (zero) or greater than 15 causes an error.

Code:
With Range("A10") 
 .IndentLevel = 15 
End With

Hello Howard,

Perhaps I need to clarify: I'd like to have VBA executed when a user uses the commandbar 'Increase Indent' or 'Decrease Indent'.

Thanks in advance.
Maarten
 
Upvote 0
I'm thinking that is not supported in events.

There are a ton of other events that will play, I could not find Indent in this link to Chip Pearson's info on events.

Events In Excel VBA

Howard
 
Upvote 0
I'm not especially hopeful, but perhaps if you tell us more about what you have on your sheet, where, and what you actually want your macro to do when an indent is changed, maybe somebody might be able to think up a work-around if the direct method you envisage turns out to be unachievable.
 
Upvote 0
In addition to my previous comment: I am tenacious, because this page from microsoft https://msdn.microsoft.com/en-us/li...e.tools.ribbon.ribbongallery.butt*******.aspx clues me that it is in fact possible: apparently with this piece of coding:

Code:
Event[/FONT][/COLOR][COLOR=#000000][FONT=Consolas] Butt******* [/FONT][/COLOR][COLOR=blue][FONT=Consolas]As[/FONT][/COLOR][COLOR=#000000][FONT=Consolas] RibbonControlEventHandler 
[/FONT][/COLOR][COLOR=#0000FF][FONT=Consolas]

Just not sure how to embed it properly in code.
 
Upvote 0
Hello Peter,

Didn't catch your comment before posting previous message, in which something went wrong too. Sorry about that. Coding should be: Event Butt******* As RibbonControlEventHandler.

What I want is the following: when the user clicks on the indent button, whether it is increase or decrease, it should trigger a calculation immediately. Indent change usually doesn't call for recalculation, because normally it doesn't affect anything, however I use a custom function that I named 'Indent'. So if I could invoke macro on the ribbon indent buttons, if only force calculation, it would be perfect.

I already thought of a workaround: to have automatic recalculation everytime another cell is selected. Seems a bit excessive but perhaps this is the only solution? Also, it poses another challenge, because I'd like to have underlying cells also indented as long as they are 'part' of the above cell. So then it would be vital that the address of previous cell is stored...
 
Upvote 0
Why would you want to recalculate a sheet in which nothing has been changed ?
 
Upvote 0
The code you are looking at on MSDN is not VBA, nor are those events available to VBA as far as I know. You would need to modify the CustomUI part of the workbook to override the buttons for increase/decrease indent and then run your calculate code in the callback. You'd also need to replicate the existing functionality in your code.
 
Upvote 0

Forum statistics

Threads
1,214,968
Messages
6,122,506
Members
449,089
Latest member
RandomExceller01

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top