+ Reply to Thread
Results 1 to 2 of 2

Problem with sheet copy API in Microsoft.Office.Interop.Excel

  1. #1
    Registered User
    Join Date
    08-18-2011
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    2

    Red face Problem with sheet copy API in Microsoft.Office.Interop.Excel

    Hello,

    Iam new to the c# and excel and iam facing one issue w.r.t. the copysheet API. Plzz let me know if there is some solution to this.

    Iam trying to copy a sheet from one excel work book to another excel workbook (both are Excel 1997-2003 .xls format). using workSheet.Copy API. Now my source excel sheet contains some cells with the data validation as a range. For ex -

    The Data Validation for the cell A1 is set as (via data validations) range =B21-B22, for
    A2 data validation is again set as (via data validations) range =B21-B22,for
    A3 data validation is again set as (via data validations) range =B21-B22

    Now after the copy of the sheet, in the target sheet what i see is

    A1 contains a data validation set as (via data validations) range =B21-B22 but
    A2 contains a data validation set as (via data validations) range =B22-B23
    A3 contains a data validation set as (via data validations) range =B23-B24


    Basically as the rows are getting copied into the new sheet, the data validation range is also increasing, and this makes A2,A3 to have totally different set of validation values. Ideally even for this it should been B21-B22.

    Is there any settings that iam supposed Do, to disable this incremental range validation. What i want is, what ever is data validation set in the source cell should be copied to destination cell. If sheet.copy API has this drawback then is there any alternative way to do a copy which doesn't have this problem

    Thanks
    Paramesh

  2. #2
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: Problem with sheet copy API in Microsoft.Office.Interop.Excel

    Code with absolute addressing is the usual solution.

+ 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