#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 108
Default Delete Rows

I have this code for deleting the last row inserted from a form. I need to
edit this so as to ignore the first row. How could I do this?
Private Sub CommandButton6_Click()
Dim LastRowOnSheet As Long

LastRowOnSheet = Sheets("Sheet1").UsedRange.Rows.Count +
Sheets("Sheet1").UsedRange.row - 1
Sheets("Sheet1").Cells(LastRowOnSheet, 1).EntireRow.Delete


End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Delete Rows

Hi Enyaw,

Try:

'=============
Private Sub CommandButton6_Click()
Dim LastRowOnSheet As Long

With ActiveWorkbook.Sheets("Sheet1")
LastRowOnSheet = .UsedRange.Rows.Count _
+ .UsedRange.Row - 1
If LastRowOnSheet 1 Then _
Rows(LastRowOnSheet).Delete
End With

End Sub
'<<=============


---
Regards,
Norman


"enyaw" wrote in message
...
I have this code for deleting the last row inserted from a form. I need to
edit this so as to ignore the first row. How could I do this?
Private Sub CommandButton6_Click()
Dim LastRowOnSheet As Long

LastRowOnSheet = Sheets("Sheet1").UsedRange.Rows.Count +
Sheets("Sheet1").UsedRange.row - 1
Sheets("Sheet1").Cells(LastRowOnSheet, 1).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
Hpw do I delete multiple empty rows found between filled rows? Bill Excel Worksheet Functions 2 November 15th 09 07:12 PM
Cut filtered rows, paste into next empty row of new sheet, and delete cut rows Scott Excel Worksheet Functions 0 December 13th 06 01:25 AM
Delete rows with numeric values, leave rows with text GSpline Excel Programming 5 October 11th 05 12:44 AM
How to delete rows when List toolbar's "delete" isnt highlighted? Linda Excel Worksheet Functions 1 May 26th 05 08:39 PM
Delete every 3rd row, then delete rows 2-7, move info f/every 2nd row up one to the end and delete the row below Annette[_4_] Excel Programming 2 September 21st 04 02:40 PM


All times are GMT +1. The time now is 08:18 AM.

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

About Us

"It's about Microsoft Excel"