Drag range of cells

Chewyhairball

Active Member
Joined
Nov 30, 2017
Messages
312
Office Version
  1. 365
Platform
  1. Windows
Hi
This probably is beyond the capabilities of VBA but i will ask anyway.

In a table range from A1 to J50 can you click on a cell in column A and drag the table row to another position in column A
eg I click on cell A5 and holding the left mouse long enough selects the row from A-J which while still holding the left mouse button allow the row to be repositioned.

The same sort of idea you have on your phone if moving stuff around for bookmarks or email folder etc...

I know it can be done other ways using vba which involves selecting the cell then selecting where you want the row to go but i was wondering
if there was a more elegant way of doing it where you just click on a cell and drag it to a new position moving the row range(not the whole row).

it seems unlikely but you never know :)

Rory
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
AFAIK you can move a selection or individual cells by the same method but only to overwrite the destination, not to insert the cells (for that you need to use copy or cut manually).

The moving the rows is the same behaviour as I get on my phone when for instance moving my playlist around i.e. you drag the song, artist, album, song length and date to a different postion in the list.
You can't just move the song without moving the other details which is similar what you asked to replicate the behaviour of in your original question (the same applies with emails or bookmarks etc.)

I know it can be done other ways using vba which involves selecting the cell then selecting where you want the row to go
In VBA you normally avoid selecting, you tell it what destination you want the source range placed in (or vice-versa) rather than doing selecting which slows the code down (depends exactly what you are trying to achieve in the code though).
 
Upvote 0
AFAIK you can move a selection or individual cells by the same method but only to overwrite the destination, not to insert the cells (for that you need to use copy or cut manually).

The moving the rows is the same behaviour as I get on my phone when for instance moving my playlist around i.e. you drag the song, artist, album, song length and date to a different postion in the list.
You can't just move the song without moving the other details which is similar what you asked to replicate the behaviour of in your original question (the same applies with emails or bookmarks etc.)


In VBA you normally avoid selecting, you tell it what destination you want the source range placed in (or vice-versa) rather than doing selecting which slows the code down (depends exactly what you are trying to achieve in the code though).

When you select a range of cells (A1:A10) then the move the cursor so the crosshairs appear then move the selection to somewhere like A20
That is what i was trying to achieve but without selecting the cells manually or positioning the crosshair.

Just click and hold on cell A1 then drag it to cell A20.

i have just discovered mouse up and down events so will play about with that
 
Upvote 0
Is there some VBA to tell me what cell my cursor is over.

I am thinking if i use a transparent commandbutton i can select the cells for moving with mousedown.
I can then move my cursor and selection-cut-paste to that cell.

VBA Code:
Private Sub CommandButton1_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
   Range(ActiveSheet.CommandButton1.TopLeftCell, ActiveSheet.CommandButton1.TopLeftCell.Offset(0, 5)).Select
  
End Sub

Private Sub CommandButton1_Mouseup(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
'paste here which is whatever cell cursor is over'
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,327
Messages
6,124,292
Members
449,149
Latest member
mwdbActuary

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