Excel:跨工作簿更新表,同时保护给定的列不被覆盖?

我有一个文件(让我们称之为OVERLORD.xlsm),其中包含一个表。 在子文件夹中,我有一些名为(OVERLORD-north.xlsm,OVERLORD-east.xlsm)的文件,它们都使用数据连接来获取存储在OVERLORD.xlsm中的表。

在每个子文件中,例如OVERLORD-north,我希望能够input一些信息,即使当我更新表的数据连接时,这些信息也是持久的。

假设OVERLORD.xlsm中包含以下内容(col A包含一个静态自动编号,我将其用作索引):

Col A - Col B - Col C 1 2 

这些内容将被回送到OVERLORD-north,但是如果我在col C(从OVERLORD-North内)input了一些内容,那么下一次从原始文件刷新信息时将覆盖此信息。

我能阻止吗?

我能以某种方式locking列,以防止其内容被覆盖,即使它们是表的一部分吗? 或者我可以select省略数据刷新查询中的某些列? 从字面上看,任何允许我为外部提取的表中的给定单元格或列创build持久性的解决scheme将是有意义的。

是的,有必要列是表的一部分,否则它们不能与索引键sorting,这是一个先决条件。 我也无法将所有信息保存在一个文件中,如果可能的话,几个月前我会select这个文件。

我有一个解决的办法,但它会杀死资源的有效性…所以我会感谢locking列的任何input,或者如果这是不可能的,提高我的列保存数组的稳定性和速度的build议-制作者。

 Sub rewriteStatus() ' Loop through array, match index number between array and sheet, and write to corresponding cell(s) into the table. End Sub Sub preserveStatus() Dim statusArray() As String, emptyRow As Boolean ReDim Preserve statusArray(1 To 4, 1 To 2) emptyRow = True For i = 2 To ListObject("PUSH_table").Count If Cells(i, 14) <> "" Then statusArray(i, 2) = Cells(i, 14).Value emptyRow = False End If If Cells(i, 15) <> "" Then statusArray(i, 3) = Cells(i, 15).Value emptyRow = False End If If Cells(i, 17) <> "" Then statusArray(i, 4) = Cells(i, 17).Value emptyRow = False End If ' ReDim array if any cell of that row was found to be non-empty ' and copy the index key for that row If emptyRow = False Then ReDim Preserve statusArray(1 To 2, 1 To UBound(statusArray, 2) + 1) statusArray(i, 1) = Cells(i, 1).Value End If Next i End Sub