試試這個,它使用一個簡單的自動篩選得到的每一行與獨特的SPOT ID,它不會做onlyh就是保持......... ..排在中間,希望這實際上並不重要。
Option Explicit
Sub SplitColumns()
Dim c As Range, wsNEW As Worksheet, NC As Long, LR As Long
Dim List As New Collection, Item As Variant
With ActiveSheet
.AutoFilterMode = False // turn autofilter off
LR = .Range("A" & .Rows.Count).End(xlUp).Row //count cells in A
On Error Resume Next //on error, continue on next line
For Each c In .Range("B:B").SpecialCells(xlConstants, xlNumbers) //Help here?
//doing something to the values in column B (the Spot IDs)
List.Add c.Value, CStr(c.Value) //Make a list of values in column A in c
Next c //For-next loop
On Error GoTo 0
.Rows(1).AutoFilter //turn autofilter on?
Set wsNEW = Sheets.Add //add a new sheet
NC = 1 //counter for columns in new sheet
For Each Item In List //exactly, but where does Item come from?
.Rows(1).AutoFilter Field:=2, Criteria1:=Item //autofilter using Item as criteria
.Range("B1:D" & LR).Copy wsNEW.Cells(1, NC) //copy everything in the range to new column in new sheet
NC = NC + 3 //iterate column by 3
Next Item // for-next loop
.AutoFilterMode = False // turn autofilter off
End With
End Sub
Definte「很多這樣的數據」。這是一次性的事情嗎? – Marc 2012-04-25 23:02:24
一個數據集中有多少個不同的「點ID」值? – 2012-04-25 23:16:52
「很多」 - 正在跟蹤的可視化數據的GB,每個數據集產生數百個跟蹤。定期生成更多數據。這是一種統計力學現象(有偏布朗運動),所以數據越多,理解就越好。 – nan0guy 2012-04-26 11:43:39