Link to home
Start Free TrialLog in
Avatar of jnash67
jnash67

asked on

Excel VBA - Drag and Drop Columns

I would like to enable a user to re-order columns.  When the user clicks down on the column header and hold the mouse down, I would like the column or some shape to become movable with the mouse.  When they let go of the mouse, I would then move the column to where they let go.

Does someone have some code that does most of this that I can cannibalize.
Avatar of Rory Archibald
Rory Archibald
Flag of United Kingdom of Great Britain and Northern Ireland image

Begs the question - why can't they just drag and drop anyway?
Avatar of jnash67
jnash67

ASKER

It's in the context of a VBA dictator application where Excel is heavily modified.

There's a lot more details about the whys at https://www.experts-exchange.com/questions/25008923/Excel-VBA-Drag-and-Drop-Columns.html
SOLUTION
Avatar of patrickab
patrickab
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jnash67

ASKER

I'm going with Rory's approach.  The problem with Patrick's approach was that the user still had to position cursor at the very edge and the program had no notification when the drag and drop was completed or where the column had been moved to.

I've started off with the code from: http://www.dailydoseofexcel.com/archives/2007/01/11/listbox-drag-and-drop/

Any ideas of how to highlight where an item is going to be dragged and dropped?  If not, any sample code for a listbox approach with an up and down button implemented?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
jnash67 - Thanks for the points - Patrick