Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Delete cells - auto move


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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default Delete cells - auto move

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

"Al" wrote in message
...

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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default Delete cells - auto move

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

On Mon, 3 Nov 2003 21:03:58 -0800, "Al" wrote:


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


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Delete cells - auto move


Forgot about the recorder .. thx for the tip.

And that is just what I was looking for.

Thx again Kev,
Al

-----Original Message-----
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

"Al" wrote in message
...

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



.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Auto-ID and Delete/left shift cells when a cell contains text? IndyToothDoc Excel Discussion (Misc queries) 0 June 29th 09 06:06 PM
Any way to use toolbar button to delete cells and move cells "up"? Texas-Ron Excel Discussion (Misc queries) 2 April 7th 07 06:33 PM
Selecting every other row to delete or move Jeanne Excel Discussion (Misc queries) 1 April 8th 06 01:53 AM
Auto-delete Unbolded Cells John Walker Excel Worksheet Functions 2 March 30th 06 09:37 PM
Have VBA delete a group of cells, move information over, then add Tina Bradshaw Excel Discussion (Misc queries) 0 February 22nd 06 04:07 PM


All times are GMT +1. The time now is 01:12 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"