Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Insert Row In Excel File

Insert Row In Excel File

Scheduled Pinned Locked Moved Visual Basic
help
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    hitesh sojitra
    wrote on last edited by
    #1

    while i try to insert row by Sheet.Rows.Insert(Shift:=Excel.XlDirection.xlDown) i get error is To prevent possible loss of data, Microsoft Office Excel cannot shift nonblank cells off the worksheet. Try to locate the last nonblank cell by pressing CTRL+END, and delete or clear all in cells between the last cell and the end of your data. Then select cell A1 and save your workbook to reset the last cell used. Or, you can move the data to a new location and try again. so please help me how insert row

    Hitesh sojitra

    P 1 Reply Last reply
    0
    • H hitesh sojitra

      while i try to insert row by Sheet.Rows.Insert(Shift:=Excel.XlDirection.xlDown) i get error is To prevent possible loss of data, Microsoft Office Excel cannot shift nonblank cells off the worksheet. Try to locate the last nonblank cell by pressing CTRL+END, and delete or clear all in cells between the last cell and the end of your data. Then select cell A1 and save your workbook to reset the last cell used. Or, you can move the data to a new location and try again. so please help me how insert row

      Hitesh sojitra

      P Offline
      P Offline
      parth p
      wrote on last edited by
      #2

      hitesh sojitra wrote:

      while i try to insert row by Sheet.Rows.Insert(Shift:=Excel.XlDirection.xlDown)

      This is because you have not selected/told excel where to insert new Row. It should be something like this.

      Sheet1.Rows("1:1").Insert Shift:=Excel.XlDirection.xlDown
      

      The code above will add new row before cell A1 so everything in row 1 will move to row 2.

      - Stop thinking in terms of limitations and start thinking in terms of possibilities -

      H 2 Replies Last reply
      0
      • P parth p

        hitesh sojitra wrote:

        while i try to insert row by Sheet.Rows.Insert(Shift:=Excel.XlDirection.xlDown)

        This is because you have not selected/told excel where to insert new Row. It should be something like this.

        Sheet1.Rows("1:1").Insert Shift:=Excel.XlDirection.xlDown
        

        The code above will add new row before cell A1 so everything in row 1 will move to row 2.

        - Stop thinking in terms of limitations and start thinking in terms of possibilities -

        H Offline
        H Offline
        hitesh sojitra
        wrote on last edited by
        #3

        Thanks a lot it's working :)

        Hitesh sojitra

        1 Reply Last reply
        0
        • P parth p

          hitesh sojitra wrote:

          while i try to insert row by Sheet.Rows.Insert(Shift:=Excel.XlDirection.xlDown)

          This is because you have not selected/told excel where to insert new Row. It should be something like this.

          Sheet1.Rows("1:1").Insert Shift:=Excel.XlDirection.xlDown
          

          The code above will add new row before cell A1 so everything in row 1 will move to row 2.

          - Stop thinking in terms of limitations and start thinking in terms of possibilities -

          H Offline
          H Offline
          hitesh sojitra
          wrote on last edited by
          #4

          one more quiry please if i wants insert 3 row after A5 than it is (5:3) ? or any thing else?

          Hitesh sojitra

          H 1 Reply Last reply
          0
          • H hitesh sojitra

            one more quiry please if i wants insert 3 row after A5 than it is (5:3) ? or any thing else?

            Hitesh sojitra

            H Offline
            H Offline
            hitesh sojitra
            wrote on last edited by
            #5

            thanks i got it..............

            Hitesh sojitra

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups