LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Import data using QueryTable somehow change sheet cells references

I have a workbook that contains five worksheets. The first worksheet have
cells that contain absolute and relative references to the other four
worksheets' cells. When I update the other four worksheets' contents by
using QueryTable to import the data from cvs files, the cells' references in
the first worksheet are changed. For example, orignally a cell contains
"=Sheet2$C#4" but after the update, the cell contains "=Sheet2$AQ$4". Anyone
knows why this happen? Any suggestions are appreciated.

Below is the code that does the importing of data.

for (int i = 1; i <= fileNames.Count; i++) //import data to the four sheets
{
string file = fileNames[i - 1] as string;
string[] split = file.Split(slash);
string name = split[split.Length -
1].Replace(Constants.TextExtension, "");

//get the correct worksheet to import data
XLS.Worksheet sheet = GetWorkSheet(sheets, name);

XLS.Range range = sheet.get_Range("A1",
SYS.Type.Missing);

XLS.QueryTables tables = sheet.QueryTables;
XLS.QueryTable table = tables.Add(Constants.ExcelText +
fileNames[i - 1], range,
SYS.Type.Missing);

table.Name = name;
table.PreserveFormatting = true;
table.RefreshOnFileOpen = false;
table.RefreshStyle = XLS.XlCellInsertionMode.xlInsertDeleteCells;
table.SaveData = true;
table.AdjustColumnWidth = true;
table.RefreshPeriod = 0;
table.TextFilePromptOnRefresh = false;
table.TextFileStartRow = 1;
table.TextFileParseType = XLS.XlTextParsingType.xlDelimited;
table.TextFileOtherDelimiter = Constants.DelimiterSymbol;
table.TextFileColumnDataTypes = GetDataTypeList(file);
table.Refresh(false);

}

thank you
Jack
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Change relative to absolute references in a block of cells Giles Excel Discussion (Misc queries) 3 January 27th 09 02:19 PM
formula references change when data entry sheet is modified ExcelKat Excel Worksheet Functions 0 June 9th 06 12:07 AM
Can't change name of querytable. Bing Excel Programming 0 March 12th 05 05:57 PM
Changing only source file of pre-existing text import QueryTable? EBrowne Excel Programming 3 August 23rd 04 03:31 AM
Using Querytable.add to import data from a closed workbook Markus Stolle[_5_] Excel Programming 8 August 3rd 04 08:51 PM


All times are GMT +1. The time now is 01:33 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"