0

我需要找到第一个单元格具有指定值的列(在除 ProfitSheet 之外的每张表上)(它始终存在并且每张表只有一个),然后将列复制到另一张表。即类似的东西:

for i := 2 to MsExcel.Sheets.Count do // sheets loop. Sheets[1] —  ProfitSheet
begin
  MsExcel.Sheets[i].Select;
  for j := 1 to 15 do // columns loop to find "Profit column"
    if MsExcel.Cells[1, j].Text = 'Profit' then
      // copy j column, usually I use something like 
      // VariantArr := MsExcel.Range[MsExcel.Cells[1, j], MsExcel.Cells[299, j]].Value
      // and then 
      // Range := MsExcel.Range[MsExcel.Cells[1,i], MsExcel.Cells[299, i]];
      // Range.Value := VariantArr;
      // but I don't know how to find last column's cell (where 299)
  MsExcel.Sheets['ProfitSheet'].Select;
  // copy col to the i column of ProfitSheet
end;
4

0 回答 0