我需要在Hej123下进行观察,将其作为列,然后将所有hej1收集到一列中,将hej2收集到第二列中,依此类推。 Hej321下面的观测值应匹配其匹配列。当前表如下所示。
我希望它像
Hej1 hej2 hej3
sahsajdh klasd laskd
等
答案 0 :(得分:0)
您可以使用VBA代码:
Option Explicit
Sub test()
Dim LastRowA As Long, i As Long, j As Long, LastRowD As Long
Dim Initials As String, strName As String
'Select your worksheet
With ThisWorkbook.Worksheets("Sheet1")
'Find the last row of sheet Sheet1 and column F
LastRowA = .Range("A" & Rows.Count).End(xlUp).Row
For j = 1 To Len(.Range("A1"))
If IsNumeric(Mid(.Range("A1").Value, j, 1)) Then
Initials = Left(.Range("A1").Value, 3)
strName = Initials & Mid(.Range("A1").Value, j, 1)
'Start loop from Lastrow to 1 (there is no 0 row)
For i = 2 To LastRowA
If strName = .Range("A" & i).Value Then
LastRowD = .Range("D" & Rows.Count).End(xlUp).Row
.Range("D" & LastRowD + 1).Value = strName
.Range("E" & LastRowD + 1).Value = .Range("B" & i).Value
Exit For
End If
Next i
End If
Next j
End With
End Sub