我有以下代码:
With WB2.Sheets("Sheet2") 'Add new book, headers, and formatting
.Range("A1").Value = "Display Name"
.Range("B1").Value = "Language"
.Range("C1").Value = "Locale"
.Range("D1").Value = "WorkType"
.Range("E1").Value = "EntryType"
.Range("F1").Value = "TitleInternalAlias"
.Range("G1").Value = "TitleDisplayUnlimited"
.Range("H1").Value = "LicenseRightsDescription"
.Range("I1").Value = "(License)Type"
.Range("J1").Value = "FormatProfile"
.Range("K1").Value = "Start"
.Range("L1").Value = "End"
.Range("M1").Value = "Description"
.Range("N1").Value = "Other Terms"
.Range("O1").Value = "Other Instructions"
.Range("P1").Value = "Content ID"
.Range("Q1").Value = "Product ID"
.Range("R1").Value = "Metadata"
.Range("S1").Value = "AltID"
.Range("T1").Value = "Release History (Original)"
.Range("U1").Value = "Release History (DVD)"
.Range("V1").Value = "Rental Duration"
.Range("W1").Value = "Watch Duration"
.Range("X1").Value = "WSP"
.Range("Y1").Value = "Tier"
.Range("Z1").Value = "SRP"
.Range("AA1").Value = "CaptionIncluded"
.Range("AB1").Value = "Caption Required"
.Range("AC1").Value = "Any"
.Range("AD1").Value = "Total Run Time (minutes)"
.Range("AE1").Value = "Total Run Time (mins.)"
End With
我知道编写此代码有一种不同且更简单的方法,因为所有值都在同一行,但列不同。有人知道吗?谢谢!
答案 0 :(得分:3)
你可以使用这样的数组:
Sub sample2()
Dim myarray
myarray = Array("Display Name", "Language", "Locale", "WorkType", ... "Total Run Time (mins.)")
Range("A1", Cells(1, UBound(myarray) + 1)).Value = myarray
End Sub
希望这有帮助。