|
本帖最后由 xdragon 于 2014-9-30 10:07 编辑
Sub test()
Dim arr, brr$(999), ar, i%, re$(999, 0), cnt%
For i = 0 To 999
brr(i) = i
Next
arr = Sheets("sheet1").Range("DE1").CurrentRegion.Value
For Each ar In arr
brr(ar) = ""
Next
For i = 0 To 999
If brr(i) <> "" Then re(cnt, 0) = Format(brr(i), "'000"): cnt = cnt + 1
Next
Sheets("sheet2").Cells(1, EmptyColumn("Sheet2", 1)).Resize(cnt, 1) = re
End Sub
Function EmptyColumn(Sheetname$, i%)
If Sheets(Sheetname).Cells(Rows.Count, i).End(xlUp).Row = 1 And Len(Sheets(Sheetname).Cells(1, i)) = 0 Then
EmptyColumn = i
Exit Function
Else
EmptyColumn = EmptyColumn(Sheetname, i + 1)
End If
End Function |
|