+ Reply to Thread
Results 1 to 5 of 5

macro to Insert rows at every change in a column

  1. #1

    macro to Insert rows at every change in a column

    hi,

    I would like to know the Macro code for Inserting rows at every change
    in a given column

    Regards

    Macro man


  2. #2
    Bernie Deitrick
    Guest

    Re: macro to Insert rows at every change in a column

    MMan,

    Try the macro below, based on column D. To change that, change the line

    Set myRange = Range("D:D")

    to reflect your actual desired column.

    --
    HTH,
    Bernie
    MS Excel MVP

    Sub TryNow()
    Dim myRow As Long
    Dim StrtRow As Long
    Dim myCol As Integer
    Dim myRange As Range

    Set myRange = Range("D:D")

    myCol = myRange.Column
    StrtRow = myRange(65536).End(xlUp).Row

    For myRow = StrtRow To 2 Step -1
    If Cells(myRow, myCol).Value <> Cells(myRow - 1, myCol).Value Then
    Cells(myRow, myCol).EntireRow.Insert
    End If
    Next myRow
    End Sub



    <[email protected]> wrote in message news:[email protected]...
    > hi,
    >
    > I would like to know the Macro code for Inserting rows at every change
    > in a given column
    >
    > Regards
    >
    > Macro man
    >




  3. #3

    Re: macro to Insert rows at every change in a column

    Hi Bernie,

    Thanks a lot for giving me this code. its great!!!!!


  4. #4

    Re: macro to Insert rows at every change in a column

    hi Bernie,

    Can you pls give me the code for defining the range through Input box
    for the code which you gave for "macro to Insert rows at every change
    in a column".

    Thanks

    Macro Man


  5. #5
    Bernie Deitrick
    Guest

    Re: macro to Insert rows at every change in a column

    Macro Man,

    Set myRange = Application.InputBox(Prompt:="Select your range", Type:=8)

    HTH,
    Bernie
    MS Excel MVP


    <[email protected]> wrote in message
    news:[email protected]...
    > hi Bernie,
    >
    > Can you pls give me the code for defining the range through Input box
    > for the code which you gave for "macro to Insert rows at every change
    > in a column".
    >
    > Thanks
    >
    > Macro Man
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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