简体   繁体   English

如何转置此Excel数据透视表工作表数据?

[英]How do I transpose this Excel pivot worksheet data?

I have a set of data in this format: 我有一组这种格式的数据:

Column1 column2 column3 22/8  23/8  24/8 25/8 26/8
A       B         C      2       3    4    5   6
D       E         F      5       6    7    7   7

I need to transpose it to this format: 我需要将其转换为以下格式:

A   B   C  22/8    2
A   B   C  23/8    3
A   B   C  24/4    4
A   B   C  25/8    5
A   B   C  26/8    6
D   E   F  22/8    5

Is it possible in Excel/Access without copying and paste special to transpose format? 是否可以在Excel / Access中无需复制并粘贴特殊的转置格式?

While finding, I realised that this worked for me. 在查找时,我意识到这对我有用。 I was able to transpose Initial Pic to After Tranposing in Access VBA coding. 我能够在Access VBA编码中将“ 初始图片”转置为“转置后”

1) I created a table(NewTypes) with the 2 fields: Column and Value 1)我创建了一个表(NewTypes)与两个字段:列和值

2) I used this set of codes: 2)我使用了这组代码:

Public Function TransposeType()
 Dim rs As DAO.Recordset, rs1 As DAO.Recordset
 Dim i As Integer, s, fldArr()

 Set rs = CurrentDb.OpenRecordset("Query1")  'change the name to the actual name of table
 Set rs1 = CurrentDb.OpenRecordset("NewTypes")  'new table created

 If rs.EOF Or rs.BOF Then
     MsgBox "no records"
     Exit Function
 End If
 rs.MoveFirst
     For i = 0 To rs.Fields.Count - 1
         ReDim Preserve fldArr(i)
         fldArr(i) = rs.Fields(i).Name
     Next
 Dim j
 Do Until rs.EOF
     For j = 1 To UBound(fldArr)
             With rs1
                 .AddNew
                 !Consign = rs("Consign") 'Field of old table=Field of new table
                                            'field that does not need to change any format
                 !Week = rs.Fields(fldArr(j))
                 .Update

             End With
     Next
     rs.MoveNext
 Loop
 End Function

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM