ibav
ibav

Reputation: 171

Using windows.arrange

I know this is supposed to be trivial but that's exactly the reason why its tough to figure out what is going wrong. I need to tile my excel windows dozens of times a day, so decided to record a macro to be a able to use a hotkey and avoid needing to press Alt+W+A Enter over and over.

Sub tile()
'
' tile Macro
'
' Keyboard Shortcut: Ctrl+e
'
    Windows.Arrange ArrangeStyle:=xlTiled
End Sub

However, when I try to run it, nothing happens. I have tried to use the hotkey and to run it directly. Is there anything about this code that should not be working properly?

Thanks.

Edit: The code works when no windows are minimized. However, when one or more windows are minimized the code will not work.

Upvotes: 1

Views: 671

Answers (3)

Siddharth Rout
Siddharth Rout

Reputation: 149305

However, when I try to run it, nothing happens. I have tried to use the hotkey and to run it directly.

There is nothing wrong with your code. You don't have to Add Excel or Application to make it work as suggested in the other answers..

You can't assign CTRL+ E to it. It is reserved for Flash Fill. When you assign the key via View Macros select your macro and click on Options. There you can set the shortcut key. If you want to use E, then type E and you will see that CTRL+SHIFT+E has been assigned for it.

enter image description here

Upvotes: 0

Gary's Student
Gary's Student

Reputation: 96753

If you have a number of windows within the same Excel application then:

Sub tile()
'
' tile Macro
'
' Keyboard Shortcut: Ctrl+e
'
    Application.Windows.Arrange ArrangeStyle:=xlArrangeStyleTiled
End Sub

Upvotes: 1

Dylan Lau
Dylan Lau

Reputation: 81

I think you need to refer to the excel application. Try changing the line to Excel.Windows.Arrange ArrangeStyle:=xlTiled

Upvotes: 0

Related Questions