我有一组这种格式的数据:
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
我需要将其转换为这种格式:
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
是否可以在Excel / Access中复制并粘贴特殊的转置格式?
答案 0 :(得分:0)
在找到时,我意识到这对我有用。 我能够转置Initial Pic 访问VBA编码中的After Tranposing。
1)我创建了一个包含2个字段的表(NewTypes):Column和Value
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