Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
D D is offline
external usenet poster
 
Posts: 121
Default Macro: Delete Row Above Last

Hi,
I am trying to create a macro to delete the line above my totals line (which
is the last line in the sheet).

I am using the following macro to delete a line but am not sure how to
modify it. Any advice is appreciated.

------
Sub DeleteLine()
Dim last_row As Long

ActiveSheet.UsedRange
last_row = Cells.SpecialCells(xlLastCell).Row

Range("A" & last_row).Select
Selection.EntireRow.Delete
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 772
Default Macro: Delete Row Above Last

Last_Row contains the last row number and you want to delete the one before
it, so change your select like this
Range("A" & last_row-1).Select
or you could change it when you set the value like this
last_row = Cells.SpecialCells(xlLastCell).Row-1

--
-John
Please rate when your question is answered to help us and others know what
is helpful.


"D" wrote:

Hi,
I am trying to create a macro to delete the line above my totals line (which
is the last line in the sheet).

I am using the following macro to delete a line but am not sure how to
modify it. Any advice is appreciated.

------
Sub DeleteLine()
Dim last_row As Long

ActiveSheet.UsedRange
last_row = Cells.SpecialCells(xlLastCell).Row

Range("A" & last_row).Select
Selection.EntireRow.Delete
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.misc
D D is offline
external usenet poster
 
Posts: 121
Default Macro: Delete Row Above Last

Thanks! I didn't realize it was that easy.

"John Bundy" wrote:

Last_Row contains the last row number and you want to delete the one before
it, so change your select like this
Range("A" & last_row-1).Select
or you could change it when you set the value like this
last_row = Cells.SpecialCells(xlLastCell).Row-1

--
-John
Please rate when your question is answered to help us and others know what
is helpful.


"D" wrote:

Hi,
I am trying to create a macro to delete the line above my totals line (which
is the last line in the sheet).

I am using the following macro to delete a line but am not sure how to
modify it. Any advice is appreciated.

------
Sub DeleteLine()
Dim last_row As Long

ActiveSheet.UsedRange
last_row = Cells.SpecialCells(xlLastCell).Row

Range("A" & last_row).Select
Selection.EntireRow.Delete
End Sub

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4
Default Macro: Delete Row Above Last



"D" wrote:

Hi,
I am trying to create a macro to delete the line above my totals line (which
is the last line in the sheet).

I am using the following macro to delete a line but am not sure how to
modify it. Any advice is appreciated.

------
Sub DeleteLine()
Dim last_row As Long

ActiveSheet.UsedRange
last_row = Cells.SpecialCells(xlLastCell).Row

Range("A" & last_row).Select
Selection.EntireRow.Delete
End Sub

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
delete macro pmss Excel Discussion (Misc queries) 2 January 3rd 08 03:10 PM
delete a macro that isn't in macro list Jane Makinson Excel Discussion (Misc queries) 3 March 13th 06 01:10 PM
How can I delete a macro when the Delete button is not active? FCR Excel Worksheet Functions 0 March 9th 06 09:43 AM
How do i delete a macro in Excel 2003 when delete isn't highlight Abel Excel Discussion (Misc queries) 2 September 13th 05 04:09 AM
Delete a whole row using a macro LaurenceL Excel Discussion (Misc queries) 1 February 17th 05 08:49 PM


All times are GMT +1. The time now is 08:53 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"