Excel buffer - export to excel clear sheet

zeonzeon Member Posts: 130
Hi,

I have an existing Excel file containing five worksheets. I need to export data from Navision to one of those worksheets.

The sheet already contains data, so I need a way to clear the sheet before I make my export. Is there a way to do that, or do I have to run through all columns and rows with data and delete their contents? I'm using Excelbuffer to export the data.

I have tried to just update the sheet with new data, but the problem is that in one situation the export is 500 rows, and the data contains data in 1000 rows, so the last 500 rows is not deleted.

/zeon

Comments

  • LADNAVLADNAV Member Posts: 2
    Hello,
    Did you solve the problem.
    I have exactly the same work to do...
    Thanks a lot
  • SogSog Member Posts: 1,023
    I haven't used excelbuffer yet, but there is an automation function which can do that for you.
    Its usedrange (part of the excel automation object) which selects all the cells in a predefined range that are not null.
    |Pressing F1 is so much faster than opening your browser|
    |To-Increase|
  • LADNAVLADNAV Member Posts: 2
    Sog,
    THX a lot.
    The "usedrange" solved my problem !
  • BeliasBelias Member Posts: 2,998
    Cells.Select
        Selection.ClearContents
    

    this is the code generated by vb excel when doing
    -select all
    -press delete

    which actually deletes all the contents...try to replicate this in nav with xls automation :mrgreen:
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
Sign In or Register to comment.