Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Jul 2003
    Location
    Cincinnati, Ohio
    Posts
    107
    Thanks
    0
    Thanked 0 Times in 0 Posts

    delete rows between defined names (2000)

    Good morning. Is it possible to delete all rows between two defined names? I have defined name 1 "memory" ( a:12) and name 2 "drives" (a:855) and would like to run a macro that will delete everything in between. thanks for any help. -scott

  2. #2
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: delete rows between defined names (2000)

    Is this what you are after?

    Steve
    <pre>Option Explicit
    Sub DeleteBetweenRanges()
    Dim lMinRow As Long
    Dim lMaxRow As Long
    Dim rng1 As Range
    Dim rng2 As Range
    Set rng1 = Range("memory")
    Set rng2 = Range("drives")

    lMinRow = Application.WorksheetFunction.Min( _
    rng1.Cells(1).Row + rng1.Rows.Count - 1, _
    rng2.Cells(1).Row + rng2.Rows.Count - 1)
    lMaxRow = Application.WorksheetFunction.Max( _
    rng1.Cells(1).Row, rng2.Cells(1).Row)
    If lMaxRow > lMinRow + 1 Then
    Range(Rows(lMinRow + 1), Rows(lMaxRow - 1)).Delete
    End If
    End Sub</pre>


  3. #3
    2 Star Lounger
    Join Date
    Jul 2003
    Location
    Cincinnati, Ohio
    Posts
    107
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: delete rows between defined names (2000)

    That did it. I wouldn't have been able to do that without your help. Thanks. -scott

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •