arrays - 将满足条件的数组值复制到另一列excel vba

标签 arrays vba excel

我想从数组中复制一组值而不是满足条件(例如值 < 70)到下一列

'Qo reported (bd) - array
For i = 0 To cap
array_Qorep(i, 0) = Range("A" & i + 1)
Cells(i + 1, 3) = array_Qorep(i, 0) 'copy array in the next column
If Cells(i + 1, 1).Value = Empty Then Exit For 'more values below, stop in blank
Next

问题是我不知道如何在数组中应用我想要的条件然后复制到下一列,有没有办法从数组中删除不满足条件的值然后复制它们?

这是解决方案,由于某种原因它以前不起作用,但现在它起作用了:)
,并感谢苦艾酒
'Qo reported (bd)

For i = 0 To cap
array_Qorep(i, 0) = Range("A" & i + 1)
If Cells(i + 1, 1).Value = Empty Then Exit For
If array_Qorep(i, 0) > Cells(3, 4) Then
    Cells(i + 1, 3) = array_Qorep(i, 0)
    End If

Next

最佳答案

这行吗?然后先构建你的数组:

arrPos  = 1

For x = 0 to myArray.length

     if myArray(x,0) < 70 then 
          cells(arrPos, 1) = myArray(x, 0)
          arrPos = arrPos + 1
     End If

next x

关于arrays - 将满足条件的数组值复制到另一列excel vba,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34243254/

相关文章:

vba - 剪切、复制和粘贴 Excel

excel - 将表导出到同一目录中的 Excel 电子表格

c++ - 结构体数组的最大大小

java - 如何将 JSON 文件转换为 Java 8 对象流?

excel - 循环工作表,排除一些并查找单元格值

ms-access - 获取 Access 表单以显示自定义类的属性值

phpexcel将图像导出到excel

arrays - 将 SAS 中的结果限制为 [-1,1]

c - 将二维数组中的数组存储在 C 中

vba - 工作表上的工作簿宏