![](/img/trans.png)
[英]excel vba copy cells to another sheet if cell value is greater than 0
[英]Can VBA keep adding cells until the sum of those added cells are greater than another cell value?
試試這個 VBA 程序。
Option Explicit
Sub HideExtraRows()
Dim PartRange As Range, cl As Range, PartTxt As String
Dim BOQty As Double, POQty As Double
PartTxt = ""
On Error Resume Next
Set PartRange = Application.InputBox("Select the Parts Range to hide extra rows", _
"Select Range", , , , , , 8)
If PartRange Is Nothing Then Exit Sub
On Error GoTo 0
For Each cl In PartRange
If cl <> PartTxt Then
PartTxt = cl
BOQty = cl.Offset(, 2)
POQty = cl.Offset(, 1)
Else
POQty = POQty + cl.Offset(, 1)
If POQty > BOQty Then cl.EntireRow.Hidden = True
End If
Next cl
End Sub
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.