Home > Software engineering >  C # call vba to realize the data generation pivot table in excel or other method excel pivot tables
C # call vba to realize the data generation pivot table in excel or other method excel pivot tables

Time:09-16

How to use c # call vba to realize the excel data generation pivot table

Existing vba code is as follows:
Sub Macro1 ()
'
'Macro1 Macro
'macro recording by Liu, time: 2018/3/2
'
'keyboard shortcut: Ctrl + x
'
ActiveWorkbook. PivotCaches. Add (SourceType:=xlDatabase SourceData:=_
"Sheet1! R1C1: R45277C8 "). CreatePivotTable TableDestination:="", the TableName:=_
"Pivot table 1," DefaultVersion:=xlPivotTableVersion10
ActiveSheet. PivotTableWizard TableDestination:=ActiveSheet. Cells (3, 1)
ActiveSheet. Cells (3, 1). Select
ActiveSheet. PivotTables (" pivot table 1). PivotFields (" article number "). The Subtotals=Array (False, _
False, False, False, False, False, False, False, False, False, False, False)
ActiveSheet. PivotTables (" pivot table 1). AddFields RowFields:=Array (" name ", "address", "shipper", _
"Article number", "the consignee")
ActiveSheet. PivotTables (" pivot table 1). PivotFields (" number "). "Orientation=xlDataField
ActiveWorkbook. ShowPivotTableFieldList=False
Application.Com mandBars (" the PivotTable "). The Visible=False
End Sub

Using the data shown in the following table


Use of c # program is provided by https://download.csdn.net/download/lzy526124/1883065


but after using the program on the original form into a read-only file and cannot be for batch operation to the source file produces no new sheel and generate PivotTable

The great god, please help




CodePudding user response:

Directly in the c # code changes the macro content added, do not run in excel macro,
In in Excel macro code. The Application after open the workbook,
The ActiveWorkbook replace Workbook object, replace ActiveSheet to replace with Workbook. Sheets [n] is assigned to WorkSheet object is ok,

CodePudding user response:

Can help me to edit it? You said I don't really know if you can have other incentives

CodePudding user response:

Can you help me achieve my code! I don't try to add is to add in if you can have some remuneration
  •  Tags:  
  • VBA
  • Related