我需要更新一个宏以向日志表中添加一些新信息以及其他一些修复。我想了解这段代码如何对数组进行排序(为什么会有3个变量),所以我在更新宏时不会破坏宏。
我了解数组的组成部分-但是我不确定循环结束后列最终如何按数组顺序排序。
Dim rang As Range
Dim i As Integer
Dim j As Integer
Dim Temp
Dim nams As Variant
Dim F
Dim Dex As Integer
nams = Array("Assay_type", "Revd_date", "Lab#", "Outside#", "Last,First
Name", "MRN", "DOB", "Requestor", "CollDate", "Sample_info",
"Order_Comment", "Signout_comment", "Sample_Comment", "Materials_recvd",
"Order_status", "DIagnosis.1", "Molec_Summary")
Set rang = Range("A1").CurrentRegion
For i = 1 To rang.Columns.Count
For j = i To rang.Columns.Count
For F = 0 To UBound(nams)
If nams(F) = rang(j) Then Dex = F: Exit For
Next F
If F < i Then
Temp = rang.Columns(i).value
rang(i).Resize(rang.Rows.Count) = rang.Columns(j).value
rang(j).Resize(rang.Rows.Count) = Temp
End If
Next j
Next i
我在数组中添加了两个新列,并且我想确保代码对它们进行排序没有问题。我只是在学习制作和更新这些宏,并且要小心。