Results 1 to 3 of 3
  1. #1
    New Lounger
    Join Date
    Sep 2002
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Assign Range Name (Excel 2000)

    I am using this code to insert a row between values if they are different.

    Sub insertLine()
    Dim cell
    For Each cell In Range("BOB")
    cell.Select
    If Selection.Offset(-1, 0) <> "" Then
    If cell <> Selection.Offset(-1, 0) Then
    Selection.EntireRow.Select
    Selection.Insert Shift:=xlUp
    End If
    End If
    Next
    End Sub

    What I would like to do is instead of assigning and using the range "Bob" I would like to use whatever range is currently selected in the worksheet.

    Any ideas would be appreciated.

    Eric

  2. #2
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Dublin, Ireland, Republic of
    Posts
    2,697
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Assign Range Name (Excel 2000)

    How about using Selection as follows :<pre>For Each cell In Selection
    If cell.Offset(-1, 0) <> "" Then
    If cell <> cell.Offset(-1, 0) Then
    cell.EntireRow.Select
    cell.Insert Shift:=xlUp
    End If
    End If
    Next</pre>

    Andrew C

  3. #3
    New Lounger
    Join Date
    Sep 2002
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Assign Range Name (Excel 2000)

    That works great. Thanks.

Posting Permissions

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