+ Reply to Thread
Results 1 to 3 of 3

If row is odd then

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    10-09-2012
    Location
    Adelaide, South Australia
    MS-Off Ver
    Excel 2010
    Posts
    135

    If row is odd then

    Hi all,
    I have made the following code but it seems to be inserting the additional row whether it is odd or even.
    I would like to insert the additional row if the current cell is ODD.

    Confused, please help.

    Sub NewPoint()
    ' Add New Range
    ' Add Test Point
        Range("Range_Results[[#Headers],[Range]]").Select
        Selection.End(xlDown).Select
        Selection.Offset(1, 0).Select
        ActiveCell.EntireRow.Insert
        Range("Range_Results[[#Headers],[Range]]").End(xlDown).Offset(1).Value = Application.Max(Range("Range_Results[Range]")) + 1
        If Selection Mod 2 = 0 Then
            Selection.Offset(2, 0).Select
            ActiveCell.EntireRow.Insert
            Else
        End If
    
        Range("Range_Results[[#Headers],[Range]]").Select
        Selection.End(xlDown).Select
    End Sub

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,247

    Re: If row is odd then

    Try:
    If Selection.Row Mod 2 = 0 Then
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Contributor
    Join Date
    10-09-2012
    Location
    Adelaide, South Australia
    MS-Off Ver
    Excel 2010
    Posts
    135

    Re: If row is odd then

    Perfect thank you Trevor, you legend! :D

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1