|
select 井控装备名称,规格型号,级别,供井数,回收数,null as 转出数,null as 转入数 from [内部井队收发明细$] union all select 井控装备名称,规格型号,级别,null,null,转出数,转入数 from [总资产变动明细$]
用NULL 替换0 就不会出现很多0了
再帮你加入 VBA 代码,能刷新了
代码:
Private Sub Workbook_Open()
Dim strCon As String, iPath As String, i As Integer, iFlag As String, iStr As String
strCon = ActiveSheet.PivotTables(1).PivotCache.Connection
Select Case Left(strCon, 5)
Case "ODBC;"
iFlag = "DBQ="
Case "OLEDB"
iFlag = "Source="
Case Else
Exit Sub
End Select
iStr = Split(Split(strCon, iFlag)(1), ";")(0)
iPath = Left(iStr, InStrRev(iStr, "\") - 1)
With ActiveSheet.PivotTables(1).PivotCache
.Connection = VBA.Replace(strCon, iPath, ThisWorkbook.Path)
.CommandText = VBA.Replace(.CommandText, iPath, ThisWorkbook.Path)
End With
End Sub |
|