粘贴到一个模块,此位的值:
Sub test()
Dim c As Long
Dim n As Long
Dim i As Integer
For i = 0 To 1023
Sheet1.Cells(i + 1, 1) = "'" & Dec2Bin(i, 10)
Next i
Sheet1.Columns(1).TextToColumns Destination:=Range("A1"), DataType:=xlFixedWidth, _
FieldInfo:=Array(Array(0, 1), Array(1, 1), Array(2, 1), Array(3, 1), Array(4, 1), Array _
(5, 1), Array(6, 1), Array(7, 1), Array(8, 1), Array(9, 1)), TrailingMinusNumbers:=True
For c = 11 To 1034
For n = 2 To 11
Sheet1.Cells(n, c) = Sheet1.Cells(c - 10, n - 1)
Sheet1.Cells(1, c) = "Case " & c - 10 & ":"
Next n
Next c
Sheet1.Columns("A:J").Delete
End Sub
Function Dec2Bin(ByVal DecimalIn As Variant, _
Optional NumberOfBits As Variant) As String
Dec2Bin = ""
DecimalIn = Int(CDec(DecimalIn))
Do While DecimalIn <> 0
Dec2Bin = Format$(DecimalIn - 2 * Int(DecimalIn/2)) & Dec2Bin
DecimalIn = Int(DecimalIn/2)
Loop
If Not IsMissing(NumberOfBits) Then
If Len(Dec2Bin) > NumberOfBits Then
Dec2Bin = "Error - Number exceeds specified bit size"
Else
Dec2Bin = Right$(String$(NumberOfBits, _
"0") & Dec2Bin, NumberOfBits)
End If
End If
End Function
请告诉我们你已经尝试过。我们还需要一个你想要的输出样本。 – 2014-09-29 18:02:32
现在的数据格式是什么? – 2014-09-29 19:29:36
只有10个数据集只有值0和1. – 2014-09-29 19:37:37