|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
有若干个sheet,每个sheet里面有一个透视表,现在要将每个透视表中的某个字段设成sheet名,应该怎么办啊
我写的代码: 提示说 x.name无效的标识,应该怎么写啊
Sub Macro1()
Dim x As Worksheet
For Each x In Worksheets
Range("A4").Select
ActiveSheet.PivotTableWizard SourceType:=xlExternal, SourceData:=Array( _
"SELECT PUMCH_ALL.ATC_CODE, PUMCH_ALL.DATA, PUMCH_ALL.YEAR, PUMCH_ALL.QTR, PUMCH_ALL.FEATURE" & Chr(13) & "" & Chr(10) & "FROM MI.PUMCH_ALL PUMCH_ALL" & Chr(13) & "" & Chr(10) & "WHERE (PUMCH_ALL.ATC_CODE=x.Name" _
, ")"), Connection:="ODBC;DSN=Oracle;UID=MI;;SERVER=MI;"
ActiveWorkbook.ShowPivotTableFieldList = True
ActiveWorkbook.ShowPivotTableFieldList = False
Next
End Sub |
|