BLk*_*krn 2 arrays excel vba excel-vba
我在excel/vba中有大量的列标题当我超过24行时,它表示有太多的行继续.我真的需要其余的列标题,因为代码必须查找我需要的每个列标题.有什么建议?
myHeaders = Array(Array("Account_ID", "Account_ID"), _
Array("Claim_ID", "Claim_ID"), _
Array("Account_Name", "Account_Name"), _
Array("Claim_Type", "Claim_Type"), _
Array("Coverage", "Coverage"), _
Array("Claim_Level", "Claim_Level"), _
Array("Claim_Count", "Claim_Count"), _
Array("File_Date", "File_Date"), _
Array("File_Year", "File_Year"), _
Array("Resolution_Date", "Resolution_Date"), _
Array("Resolution_Year", "Resolution_Year"), _
Array("Claim_Status", "Claim_Status"), _
Array("Indemnity_Paid", "Indemnity_Paid"), _
Array("Disease_Category", "Disease_Category"), _
Array("State_Filed", "State_Filed"), _
Array("First_Exposure_Date", "First_Exposure_Date"), _
Array("Last_Exposure_Date", "Last_Exposure_Date"), _
Array("Claimant_Employee", "Claimant_Employee"), _
Array("Next", "Next"))
Run Code Online (Sandbox Code Playgroud)
Mat*_*don 10
Clippy弹出
Scripting.Dictionary.您想要参考Microsoft Scripting Runtime库吗?这样你可以在你想要的任意数量的行上使用它,并保持可读性,没有任何行继续:
Dim headings As New Scripting.Dictionary
With headings
.Add "Account_ID", "Account_ID"
.Add "Claim_ID", "Claim_ID"
.Add "Account_Name", "Account_Name"
'...
'...
'...
.Add "Next", "Next"
End With
Run Code Online (Sandbox Code Playgroud)
然后你可以迭代Keys和Values; 请注意,这Keys必须是唯一的,但如果您的列标题是实际的表标题,那么它的唯一性已经由Excel强制执行.
这就是说,我不知道我理解为什么你做你正在做什么.如果您的代码按预期工作,我建议您将其转移到Code Review进行调整.我的意思是消耗这个数组的整个过程.我确信有更多,更好的方法来做到这一点.