For i = 1 To row_right / 2 name_return1(1, i + 1) = .Cells(1, i * 2).Value name_return1(6, i + 1) = .Cells(2, i * 2).Value For j = vr_time + 5 To row_end 'j-1 If (.Cells(j - vr_time, i * 2).Value <> "NAV" And .Cells(j, i * 2).Value <> "NAV" And .Cells(j - vr_time, i * 2).Value <> 0 And .Cells(j, i * 2).Value <> 0) Then name_return(j + 2 - vr_time, i + 1) = (.Cells(j, i * 2).Value - .Cells(j - vr_time, i * 2).Value) / .Cells(j - vr_time, i * 2).Value Else name_return(j + 2 - vr_time, i + 1) = "NAV" End If Next j Next i
时间: 2024-02-14 18:25:29 浏览: 20
这段代码使用了两个嵌套的For循环来遍历行和列,并在每个单元格上执行一些操作。下面是代码的解释:
```vba
For i = 1 To row_right / 2
' 在数组 name_return1 中存储单元格的值
name_return1(1, i + 1) = .Cells(1, i * 2).Value
name_return1(6, i + 1) = .Cells(2, i * 2).Value
' 在数组 name_return 中存储计算结果
For j = vr_time + 5 To row_end 'j-1
' 检查单元格的值是否满足条件,如果满足则进行计算,否则将结果设为 "NAV"
If (.Cells(j - vr_time, i * 2).Value <> "NAV" And .Cells(j, i * 2).Value <> "NAV" And .Cells(j - vr_time, i * 2).Value <> 0 And .Cells(j, i * 2).Value <> 0) Then
name_return(j + 2 - vr_time, i + 1) = (.Cells(j, i * 2).Value - .Cells(j - vr_time, i * 2).Value) / .Cells(j - vr_time, i * 2).Value
Else
name_return(j + 2 - vr_time, i + 1) = "NAV"
End If
Next j
Next i
```
在这段代码中,`i` 和 `j` 是循环变量,它们分别用来遍历列和行。`row_right`、`vr_time` 和 `row_end` 是变量或者常量,它们的值需要在代码中给出或者提前定义。代码主要的功能是将从单元格中获取的值存储到相应的数组中,并根据一定的条件进行计算,并将结果存储在另一个数组中。
请注意,这段代码是根据你提供的片段进行的解释,如果需要更详细的帮助,请提供更多上下文或完整的代码。
相关推荐
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![cs](https://img-home.csdnimg.cn/images/20210720083646.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
<script> function goToLink(link) { window.location = link; } </script> <input type="checkbox" id="select-all"> 录入时间 退货单号 录入人 备注 状态 日志 {%for item in data%} <input type="checkbox" value="{{item[1]}}" name="id"> {{item[0]}} {{item[1]}} {{item[2]}} {{item[3]}} {% if item[4] is none %}{% else %}{{item[4]}}{% endif %} 日志 {%endfor%} <script> var rows = document.getElementsByTagName("tr"); for (var i = 0; i < rows.length; i++) { var row = rows[i]; var tuihuodanhao = row.cells[1].innerHTML; if (tuihuodanhao === {{tuihuodanhao}}) { row.classList.add("selected"); } } </script> <script> function fun(ido,page){ var textDiv= document.getElementById(ido); var url="{{ url_for('shouhou.show_tui') }}?page="+page+"&keyword={% if keyword!=None %}{{keyword}}{% endif %}"; return textDiv.setAttribute("href",url); } </script>为什么行背景没有变色
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)