Results 1 to 2 of 2

Thread: How delete rows between two inputs numbers on Excel?

  1. #1
    Join Date
    Nov 2011
    Posts
    61

    How delete rows between two inputs numbers on Excel?

    Hi
    I need help with a small macro. I need to enter two numbers in message boxes , and then delete the rows between the two input numbers. If the second number is entered as 'last row' , then it would delete between the first number entered and the bottom row , whatever number row it may be. Can someone help with some code? Grateful for any help.

  2. #2
    Join Date
    Nov 2010
    Posts
    422

    Re: How delete rows between two inputs numbers on Excel?

    Try the below mentioned code and let me know whether it is helpful or not.

    Code:
    Sub rowKiller()
    Dim n1 As String, n2 As String, s As String
    n1 = Application.InputBox(prompt:="enter first row", Type:=2)
    n2 = Application.InputBox(prompt:="enter last row", Type:=2)
    If n2 = "last row" Then
    n2 = CStr(Rows.Count)
    End If
    s = n1 & ":" & n2
    Rows(s).Delete
    End Sub

Similar Threads

  1. Replies: 6
    Last Post: 23-07-2011, 01:05 AM
  2. display all the odd numbers between the range the user inputs
    By MaryJ in forum Software Development
    Replies: 1
    Last Post: 22-11-2010, 05:13 PM
  3. How to delete bottom rows in excel
    By Dhanajay in forum Windows Software
    Replies: 2
    Last Post: 25-06-2009, 12:22 PM
  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,711,636,515.34075 seconds with 17 queries