Macro to move two cells up deleting the two above cell

bumperjoe

New Member
Joined
Feb 4, 2006
Messages
33
hello,
I need to move a cell (A2) and it's adjacent cell(B2) up and delete the two cells above it (A1) and (B1)



Thanks
 
Last edited:

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Re: how to use a macro to move two cells up deleting the two above cell

as I applied it tonight it shifts up all the cells below it, not just the 4 cells involved
so the column does not keep its integrity
 
Upvote 0
Re: how to use a macro to move two cells up deleting the two above cell

Any time you delete a cell all the cells below must shift up or left or right

You cannot just leave a empty hole.

Or do you just want to clear the values in the cells.
 
Upvote 0
Re: how to use a macro to move two cells up deleting the two above cell

Now in your original post you said this:
I need to move a cell (A2) and it's adjacent cell(B2) up and delete the two cells above it (A1) and (B1)

So My script will now clear the cell you double click on and the cell to the right of it.

Now if your doing this with columns

1 4 and 5 you will have a problem because:

When you double click on value in column 4 it will clear value in column 4 and 5

So try this:

Works on columns 4 5 and 6
Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
'Modified 1-31-18 11:00 PM EST
If Target.Column = 1 Or Target.Column = 4 Or Target.Column = 5 Then
Cancel = True
Target.Resize(, 2).ClearContents
End If
End Sub
 
Upvote 0
Re: how to use a macro to move two cells up deleting the two above cell

I cannot get it to work
The columns are H and I
I would like 7.00 and 4.90 to move up and 1.00 and 3.00 to delete without shifting up the column


"H"...."I"
1.00... 3.00
7.00... 4.90
to
H.....I
7.00 4.90
 
Last edited:
Upvote 0
Re: how to use a macro to move two cells up deleting the two above cell

I getting confused:

Yesterday you said:

Post 8 you said: thank you. it work so great!
Post 10 you said: that is awesome. thanks again joe

But now tonight it seems as nothing now works the way you want.



 
Upvote 0
Re: how to use a macro to move two cells up deleting the two above cell

You just said:

I would like 7.00 and 4.90 to move up and 1.00 and 3.00 to
delete
without shifting up the column

You cannot delete a cell without it shifting up left or right
 
Upvote 0
Re: how to use a macro to move two cells up deleting the two above cell

I did not notice it was shifting up the column H and I . I looked at the end of the sheet and "H" and "I" were empty.
if you cannot delete without shifting like you would went you just hit the delete key then I guess it will not work
 
Last edited:
Upvote 0
Re: how to use a macro to move two cells up deleting the two above cell

When you press the delete key you are not deleting a cell. You are clearing the contents of a cell.
 
Upvote 0

Forum statistics

Threads
1,216,434
Messages
6,130,597
Members
449,584
Latest member
c_clark

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