Delete cells - auto move

A

Al

You know when you Delete cells in Excel, it asks you if
you want to move the cells up or left to fill in the gap.

What is the code to Delete a Range (A4:B6) and then
automatically have the cells move up to fill the gap?


Thx,
Al
 
K

Kevin Stecyk

Al,

You could just turn on the recorder to discover the code.

You would find something like.....

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 03.11.2003 by Kevin Stecyk
'

'
Range("A4:B6").Select
Selection.Delete Shift:=xlUp
End Sub


I think you could simplify the code slightly as follows:

Sub Macro1()
Range("A4:B6").Delete Shift:=xlUp
End Sub


Hope that helps.

Regards,
Kevin
 
G

Gord Dibben

Al

Sub Delete_Shift_Up()
Range("A4:B6").Delete Shift:=xlUp
End Sub

More generic....Selection.Delete Shift:=xlUp......you pre-select the range

Gord Dibben XL2002
 
A

Al

Forgot about the recorder .. thx for the tip.

And that is just what I was looking for.

Thx again Kev,
Al
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top