试试这个,它使用一个简单的 AUTOFILTER 来获取具有唯一 SPOT ID 的每一行,它唯一没有做的是将 ... ... ... ... 行保持在中间,希望不是实际上很关键。
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