+ Reply to Thread
Results 1 to 5 of 5

VBA code to add rows

  1. #1
    Kiran
    Guest

    VBA code to add rows

    Can anyone let me know the code to add rows on a button click.
    Thnx

  2. #2
    FSt1
    Guest

    RE: VBA code to add rows

    hi,
    To add a row to the sheet.....
    Rows("6:6").Select
    Selection.Insert Shift:=xlDown

    To add a row to a range.........
    Range("A6:I6").Select
    Selection.Insert Shift:=xlDown

    FSt1

    "Kiran" wrote:

    > Can anyone let me know the code to add rows on a button click.
    > Thnx


  3. #3
    Kiran
    Guest

    RE: VBA code to add rows

    Hi FST1,
    thanks for replying. But I does not solve, what this code is doing is moving
    the data from the selected row. I dont want to move data. When I click the
    Get me a New Row button, I want to generate a new row.
    So basically automating
    Right-click -> Insert Row below the selected cell.

    Hope i was clearer this time

    "FSt1" wrote:

    > hi,
    > To add a row to the sheet.....
    > Rows("6:6").Select
    > Selection.Insert Shift:=xlDown
    >
    > To add a row to a range.........
    > Range("A6:I6").Select
    > Selection.Insert Shift:=xlDown
    >
    > FSt1
    >
    > "Kiran" wrote:
    >
    > > Can anyone let me know the code to add rows on a button click.
    > > Thnx


  4. #4
    FSt1
    Guest

    RE: VBA code to add rows

    hi,
    the code is adding a row. it has to "move" the data to add the row.
    If you want the row added below certain data, then select the cell below the
    data then run the code.
    example:
    You have data on row 6 and wish to add a row below it.
    Click anywhere on row 7

    Selection.entirerow.Insert Shift:=xlDown

    FSt1

    "Kiran" wrote:

    > Hi FST1,
    > thanks for replying. But I does not solve, what this code is doing is moving
    > the data from the selected row. I dont want to move data. When I click the
    > Get me a New Row button, I want to generate a new row.
    > So basically automating
    > Right-click -> Insert Row below the selected cell.
    >
    > Hope i was clearer this time
    >
    > "FSt1" wrote:
    >
    > > hi,
    > > To add a row to the sheet.....
    > > Rows("6:6").Select
    > > Selection.Insert Shift:=xlDown
    > >
    > > To add a row to a range.........
    > > Range("A6:I6").Select
    > > Selection.Insert Shift:=xlDown
    > >
    > > FSt1
    > >
    > > "Kiran" wrote:
    > >
    > > > Can anyone let me know the code to add rows on a button click.
    > > > Thnx


  5. #5
    PegL
    Guest

    RE: VBA code to add rows

    Now I'm not sure what you're really trying to do. The code FST1 provided
    inserts a row above row 6. You'd obviously modify it to insert where you
    want it. If you want to insert after a certain location, simply reference
    the cell below it. Technically, you can't add a row in Excel. It has 65536
    rows, period.

    "Kiran" wrote:

    > Hi FST1,
    > thanks for replying. But I does not solve, what this code is doing is moving
    > the data from the selected row. I dont want to move data. When I click the
    > Get me a New Row button, I want to generate a new row.
    > So basically automating
    > Right-click -> Insert Row below the selected cell.
    >
    > Hope i was clearer this time
    >
    > "FSt1" wrote:
    >
    > > hi,
    > > To add a row to the sheet.....
    > > Rows("6:6").Select
    > > Selection.Insert Shift:=xlDown
    > >
    > > To add a row to a range.........
    > > Range("A6:I6").Select
    > > Selection.Insert Shift:=xlDown
    > >
    > > FSt1
    > >
    > > "Kiran" wrote:
    > >
    > > > Can anyone let me know the code to add rows on a button click.
    > > > Thnx


+ 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