Results 1 to 3 of 3

Thread: How to delete bottom rows in excel

  1. #1
    Join Date
    Apr 2009
    Posts
    7

    How to delete bottom rows in excel

    I want to delete bottom rows in excel. I saved my data till 198 rows in excel rest of the rows i want to delete can anyone know how delete bottom rows in excel ?

    Thanks

  2. #2
    Join Date
    Dec 2008
    Posts
    86

    Re: How to delete bottom rows in excel

    Drag from row 198 and drag until the last row. Then right-click one of the numbers on the left, click Delete. It will delete everything from bottom rows.

  3. #3
    Join Date
    May 2008
    Posts
    171

    Re: How to delete bottom rows in excel

    • Copy the following Code.
      Code:
      Option Explicit 
       
      Sub TrimAllSheets() 
           
          Dim cs As String 
          cs = ActiveSheet.Name 
          Dim y As Integer 
          y = Application.InputBox("How many bottom rows do you wish to delete?", _ 
          Default:=3, Type:=1) 'Change default number (3) if desired.
          If MsgBox("Are you sure you wish to delete " & y & " rows from the bottom of ALL sheets?", _ 
          vbYesNo, "Trim ALL Sheets") = vbNo Then Exit Sub 
          Application.ScreenUpdating = False 
          Dim r As Range, s As Range 
          Dim ws As Worksheet 
          On Error Resume Next 'Error handler
          For Each ws In ThisWorkbook.Worksheets 
              ws.Activate 
              Set r = ActiveSheet.Range("A65536").End(xlUp).Offset(-y + 1) 
              Set s = ActiveSheet.Range("A65536").End(xlUp) 
              If ActiveCell.Row < 10 Then Goto circumv 'Not to delete Headers
              Range(r, s).EntireRow.Delete 
      circumv: 
          Next ws 
          Sheets(cs).Activate 
          Application.ScreenUpdating = True 
           
      End Sub
    • Open any workbook.
    • Press Alt + F11 to open the Visual Basic Editor (VBE).
    • From the Menu, choose Insert-Module.
    • Paste the code into the right-hand code window.
    • Close the VBE, save the file if desired.


    Source : vbaexpress

Similar Threads

  1. How delete rows between two inputs numbers on Excel?
    By Hridayeshu in forum Windows Software
    Replies: 1
    Last Post: 04-01-2012, 07:56 PM
  2. Replies: 6
    Last Post: 23-07-2011, 01:05 AM
  3. Replies: 2
    Last Post: 09-07-2009, 08:57 AM
  4. Excel macro variable to delete rows
    By JPGargoyle in forum Windows Software
    Replies: 2
    Last Post: 22-06-2009, 11:26 AM
  5. Delete rows in Excel [VB]
    By Janet J in forum Software Development
    Replies: 2
    Last Post: 03-02-2009, 07:31 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,960,806.28245 seconds with 17 queries