互联网人,我需要您的帮助!我正在尝试使用变体数组将性能数据的大型数据集汇总为单个分数。
我有一张约有13000行和约1500名员工的表。
我对VBA并不陌生,并且以前使用过此方法,所以我不知道出了什么问题。
当for循环超过数组的UBound时,我要么得到一个“下标超出范围”,要么不管“结束”还是“下一个”,一堆“下一个没有For”,“没有选择就结束选择”有没有。
请帮助?
Sub createScore()
Dim loData As ListObject
Dim arrData() As Variant, arrSummary As Variant
Dim lRowCount As Long, a As Long, b As Long
Set loData = Sheets("DataMeasure").ListObjects("tbl_g2Measure")
arrData = loData.DataBodyRange
lRowCount = Range("A6").Value
Range("A8").Select
For a = 1 To lRowCount
Selection.Offset(1, 0).Select
For b = LBound(arrData) To UBound(arrData)
If arrData(b, 2) = Selection Then
Select Case arrData(b, 8)
Case "HIT"
Selection.Offset(0, 3) = Selection.Offset(0, 3) + 1
End Select
End If
Next b
Next a
Range("A8").Select
End Sub
答案 0 :(得分:0)
无需使用Select
即可快速重写。不过,这仍然无法从阵列中获得任何收益。
Sub createScore()
Dim loData As ListObject
Dim arrData() As Variant, arrSummary As Variant
Dim lRowCount As Long, a As Long, b As Long
Set loData = Sheets("DataMeasure").ListObjects("tbl_g2Measure")
arrData = loData.DataBodyRange
lRowCount = Range("A6").Value
' Update with correct sheet reference
With ActiveSheet.Range("A8")
For a = 1 To lRowCount
For b = LBound(arrData, 1) To UBound(arrData, 1)
If arrData(b, 2) = .Offset(a, 0).Value2 And arrData(b, 8) = "HIT" Then
.Offset(a, 3) = .Offset(a, 4)
End If
Next b
Next a
End With
End Sub
答案 1 :(得分:0)
我需要在用户列表重复的地方做类似的事情,所以我创建了一个唯一的用户名数组:
public static void main(String[] arguments)
{
try {
String storage_account = "wasbvalidation";
String container = "demoengagement1";
CloudBlobClient blobClient = getBlobClient(storage_account);
CloudBlobContainer blobContainer = blobClient.getContainerReference(container);
blobContainer.downloadAttributes(); // This call succeeds
SharedAccessBlobPolicy policy = new SharedAccessBlobPolicy();
policy.setPermissions(EnumSet.allOf(SharedAccessBlobPermissions.class));
policy.setSharedAccessStartTime(Date.valueOf(LocalDate.now().minusYears(2)));
policy.setSharedAccessExpiryTime(Date.valueOf(LocalDate.now().plusYears(2)));
String sas = blobContainer.getUri().toString() + "?" + blobContainer.generateSharedAccessSignature(policy, null, null, SharedAccessProtocols.HTTPS_ONLY);
// Code after this point is emulating what HDFS is doing, so I'd rather not change it.
URI blobUri = new URI(blobContainer.getUri().toString());
StorageCredentials credentials = new StorageCredentialsSharedAccessSignature(sas);
CloudBlobContainer sasContainer = new CloudBlobContainer(blobUri, credentials);
sasContainer.downloadAttributes(); // This call fails, however.
} catch (Exception e) {
e.printStackTrace();
}
}
private static CloudBlobClient getBlobClient(String storageAccount) throws NullPointerException {
String storageConnectionString = "DefaultEndpointsProtocol=https;" + "AccountName=" + storageAccount + ";" + "AccountKey=" + accountKey;
CloudStorageAccount csa = null;
try {
csa = CloudStorageAccount.parse(storageConnectionString);
} catch (Exception ex) {
ex.printStackTrace();
}
CloudBlobClient blobClient = csa.createCloudBlobClient();
return blobClient;
}