我不是一个程序员。我被分配了重新组织 xml 文件的任务,该文件包含 7,000 个产品,每个产品有 60 个属性。该文件需要重新组织,使 60 个属性成为标题,产品及其属性列在它们的下方。我有一些代码可以做到这一点,但它并不完全有效(实际上它似乎有效,它只是永远不会“完成”)。
Sub Autosort()
Dim x As Long
Dim CL As Range
With Sheets("sheet1")
For Each CL In Range("A2:A" & .Cells(.Rows.Count, "A").End(xlUp).Row)
Select Case CL.Value
Case "description"
.Range("C" & (.Cells(.Rows.Count, "E").End(xlUp).Row + 1)).Value = CL.Offset(, 1).Value
Case "origin-zip"
.Range("D" & (.Cells(.Rows.Count, "E").End(xlUp).Row + 1)).Value = CL.Offset(, 1).Value
Case "name"
.Range("E" & (.Cells(.Rows.Count, "E").End(xlUp).Row + 1)).Value = CL.Offset(, 1).Value
Case "download"
.Range("F" & (.Cells(.Rows.Count, "E").End(xlUp).Row)).Value = CL.Offset(, 1).Value
Case "yahoo-shopping-category"
.Range("G" & (.Cells(.Rows.Count, "E").End(xlUp).Row)).Value = CL.Offset(, 1).Value
Case "abstract"
.Range("H" & (.Cells(.Rows.Count, "E").End(xlUp).Row)).Value = CL.Offset(, 1).Value
Case "product-size"
.Range("I" & (.Cells(.Rows.Count, "E").End(xlUp).Row)).Value = CL.Offset(, 1).Value
Case "cross-sell"
.Range("J" & (.Cells(.Rows.Count, "E").End(xlUp).Row)).Value = CL.Offset(, 1).Value
Case "label"
.Range("K" & (.Cells(.Rows.Count, "E").End(xlUp).Row)).Value = CL.Offset(, 1).Value
Case "free-shipping"
.Range("L" & (.Cells(.Rows.Count, "E").End(xlUp).Row)).Value = CL.Offset(, 1).Value
Case "multi-box-weights"
.Range("M" & (.Cells(.Rows.Count, "E").End(xlUp).Row)).Value = CL.Offset(, 1).Value
Case "orderable"
.Range("N" & (.Cells(.Rows.Count, "E").End(xlUp).Row)).Value = CL.Offset(, 1).Value
Case "product-url"
.Range("O" & (.Cells(.Rows.Count, "E").End(xlUp).Row)).Value = CL.Offset(, 1).Value
Case "taxable"
.Range("P" & (.Cells(.Rows.Count, "E").End(xlUp).Row)).Value = CL.Offset(, 1).Value
Case "adwords_grouping"
.Range("Q" & (.Cells(.Rows.Count, "E").End(xlUp).Row)).Value = CL.Offset(, 1).Value
Case "availability"
.Range("R" & (.Cells(.Rows.Count, "E").End(xlUp).Row)).Value = CL.Offset(, 1).Value
Case "headline"
.Range("S" & (.Cells(.Rows.Count, "E").End(xlUp).Row)).Value = CL.Offset(, 1).Value
Case "markup"
.Range("T" & (.Cells(.Rows.Count, "E").End(xlUp).Row)).Value = CL.Offset(, 1).Value
Case "size"
.Range("U" & (.Cells(.Rows.Count, "E").End(xlUp).Row)).Value = CL.Offset(, 1).Value
Case "keywords"
.Range("V" & (.Cells(.Rows.Count, "E").End(xlUp).Row)).Value = CL.Offset(, 1).Value
Case "inset"
.Range("W" & (.Cells(.Rows.Count, "E").End(xlUp).Row)).Value = CL.Offset(, 1).Value
Case "code"
.Range("X" & (.Cells(.Rows.Count, "E").End(xlUp).Row)).Value = CL.Offset(, 1).Value
Case "multi-box-dimensions"
.Range("Y" & (.Cells(.Rows.Count, "E").End(xlUp).Row)).Value = CL.Offset(, 1).Value
Case "icon"
.Range("Z" & (.Cells(.Rows.Count, "E").End(xlUp).Row)).Value = CL.Offset(, 1).Value
Case "free-shipping-method"
.Range("AA" & (.Cells(.Rows.Count, "E").End(xlUp).Row)).Value = CL.Offset(, 1).Value
Case "dimensions"
.Range("AB" & (.Cells(.Rows.Count, "E").End(xlUp).Row)).Value = CL.Offset(, 1).Value
Case "caption"
.Range("AC" & (.Cells(.Rows.Count, "E").End(xlUp).Row)).Value = CL.Offset(, 1).Value
Case "gender"
.Range("AD" & (.Cells(.Rows.Count, "E").End(xlUp).Row)).Value = CL.Offset(, 1).Value
Case "hide-contents"
.Range("AE" & (.Cells(.Rows.Count, "E").End(xlUp).Row)).Value = CL.Offset(, 1).Value
Case "adwords_labels"
.Range("AF" & (.Cells(.Rows.Count, "E").End(xlUp).Row)).Value = CL.Offset(, 1).Value
Case "brand"
.Range("AG" & (.Cells(.Rows.Count, "E").End(xlUp).Row)).Value = CL.Offset(, 1).Value
Case "vwd-enable-multi-cart"
.Range("AH" & (.Cells(.Rows.Count, "E").End(xlUp).Row)).Value = CL.Offset(, 1).Value
Case "global-free-ship-exclusion"
.Range("AI" & (.Cells(.Rows.Count, "E").End(xlUp).Row)).Value = CL.Offset(, 1).Value
Case "age-group"
.Range("AJ" & (.Cells(.Rows.Count, "E").End(xlUp).Row)).Value = CL.Offset(, 1).Value
Case "number-of-boxes"
.Range("AK" & (.Cells(.Rows.Count, "E").End(xlUp).Row)).Value = CL.Offset(, 1).Value
Case "condition"
.Range("AL" & (.Cells(.Rows.Count, "E").End(xlUp).Row)).Value = CL.Offset(, 1).Value
Case "sale-price"
.Range("AM" & (.Cells(.Rows.Count, "E").End(xlUp).Row)).Value = CL.Offset(, 1).Value
Case "color"
.Range("AN" & (.Cells(.Rows.Count, "E").End(xlUp).Row)).Value = CL.Offset(, 1).Value
Case "multi-add"
.Range("AO" & (.Cells(.Rows.Count, "E").End(xlUp).Row)).Value = CL.Offset(, 1).Value
Case "exclude-states"
.Range("AP" & (.Cells(.Rows.Count, "E").End(xlUp).Row)).Value = CL.Offset(, 1).Value
Case "flat-ship-rates"
.Range("AQ" & (.Cells(.Rows.Count, "E").End(xlUp).Row)).Value = CL.Offset(, 1).Value
Case "inset-1"
.Range("AR" & (.Cells(.Rows.Count, "E").End(xlUp).Row)).Value = CL.Offset(, 1).Value
Case "ysw-alt-tag"
.Range("AS" & (.Cells(.Rows.Count, "E").End(xlUp).Row)).Value = CL.Offset(, 1).Value
Case "inset-2"
.Range("AT" & (.Cells(.Rows.Count, "E").End(xlUp).Row)).Value = CL.Offset(, 1).Value
Case "inset-3"
.Range("AU" & (.Cells(.Rows.Count, "E").End(xlUp).Row)).Value = CL.Offset(, 1).Value
Case "inset-4"
.Range("AV" & (.Cells(.Rows.Count, "E").End(xlUp).Row)).Value = CL.Offset(, 1).Value
Case "inset-5"
.Range("AW" & (.Cells(.Rows.Count, "E").End(xlUp).Row)).Value = CL.Offset(, 1).Value
Case "invalid-ship-methods"
.Range("AX" & (.Cells(.Rows.Count, "E").End(xlUp).Row)).Value = CL.Offset(, 1).Value
Case "map-price"
.Range("AY" & (.Cells(.Rows.Count, "E").End(xlUp).Row)).Value = CL.Offset(, 1).Value
Case "new-icon"
.Range("AZ" & (.Cells(.Rows.Count, "E").End(xlUp).Row)).Value = CL.Offset(, 1).Value
Case "ship-alone"
.Range("BA" & (.Cells(.Rows.Count, "E").End(xlUp).Row)).Value = CL.Offset(, 1).Value
Case "ypath"
.Range("BB" & (.Cells(.Rows.Count, "E").End(xlUp).Row)).Value = CL.Offset(, 1).Value
Case "sale-icon"
.Range("BC" & (.Cells(.Rows.Count, "E").End(xlUp).Row)).Value = CL.Offset(, 1).Value
Case "image"
.Range("BD" & (.Cells(.Rows.Count, "E").End(xlUp).Row)).Value = CL.Offset(, 1).Value
Case "ship-weight"
.Range("BE" & (.Cells(.Rows.Count, "E").End(xlUp).Row)).Value = CL.Offset(, 1).Value
Case "page-title"
.Range("BF" & (.Cells(.Rows.Count, "E").End(xlUp).Row)).Value = CL.Offset(, 1).Value
Case "gift-certificate"
.Range("BG" & (.Cells(.Rows.Count, "E").End(xlUp).Row)).Value = CL.Offset(, 1).Value
Case "flat-ship-rate"
.Range("BH" & (.Cells(.Rows.Count, "E").End(xlUp).Row)).Value = CL.Offset(, 1).Value
Case "exclude-countries"
.Range("BI" & (.Cells(.Rows.Count, "E").End(xlUp).Row)).Value = CL.Offset(, 1).Value
Case "google-based-property-type"
.Range("BJ" & (.Cells(.Rows.Count, "E").End(xlUp).Row)).Value = CL.Offset(, 1).Value
Case "price"
.Range("BK" & (.Cells(.Rows.Count, "E").End(xlUp).Row)).Value = CL.Offset(, 1).Value
Case Else
End Select
Bail:
Next CL
.Columns.AutoFit
End With
End Sub
如果您需要数据样本,请告诉我,我很乐意通过电子邮件发送一个片段。提前致谢。