这适用于带有宏的Excel。我真的迷失在这里。我真的很感激任何帮助。
function emptyForm(){
var form = document.getElementBy('myForm');
for(var input in form.children) input.value='';
for(var select in form.children) select.selectedIndex = 42; // replace 42 with whatever you want, you can also use something else then selectedIndex.
}
答案 0 :(得分:2)
如果有帮助,我会为您评论您的代码:
'Select the sheet named "5. Resume"
Sheets("5. Resume").Select
'Select the pivot table named "PivotTable1" on the active sheet ("5. Resume")
ActiveSheet.PivotTables("PivotTable1").PivotSelect "'Tarea IS'[All]", _
xlLabelOnly, True
'Refresh the data in "PivotTable1" on the selected sheet ("5. Resume") from the source
ActiveSheet.PivotTables("PivotTable1").PivotCache.Refresh
'Select the pivot table named "PivotTable2" on the active sheet ("5. Resume")
ActiveSheet.PivotTables("PivotTable2").PivotSelect "'Tarea IS'[All]", _
xlLabelOnly, True
'Refresh the data in "PivotTable1" on the selected sheet ("5. Resume") from the source
ActiveSheet.PivotTables("PivotTable2").PivotCache.Refresh
'Select the sheet named "6. Reg Err"
Sheets("6. Reg Err").Select
'Refresh the data in "PivotTable3" on the selected sheet ("6. Reg Err") from the source
ActiveSheet.PivotTables("PivotTable3").PivotCache.Refresh
您选择枢轴表的行似乎无关紧要,因为您在不对当前所选项目执行任何操作后不久更改选择(我猜这是录制的)。您可以删除.PivotSelect
行,但不会改变结果。
ActiveSheet.PivotTables("PivotTable1").PivotSelect "'Tarea IS'[All]", _
xlLabelOnly, True
事实上,以下代码以更短的方式实现了相同的目标:
With Sheets("5. Resume")
.PivotTables("PivotTable1").PivotCache.Refresh
.PivotTables("PivotTable2").PivotCache.Refresh
End With
Sheets("6. Reg Err").PivotTables("PivotTable3").PivotCache.Refresh