![](/img/trans.png)
[英]I have one excel spreadsheet with 1251 rows and one with 1800 rows. How might I find the 549 rows that are not in the 1251 row sheet?
[英]Looping through a large spreadsheet row by row that is filtered and has hidden rows. How do I copy the previous visible rows and make a table?
我的程序是这样的:
我的总金额(从0美元到2.6亿美元)一直在持续。 每行都有与成本相关的数据。 我的目标是在预算增加时提取每一行,例如增加500万美元,因此我将提取在总行列中依次包含490万美元,990万美元和1490万美元(略低于500万美元)的行。 为此,我创建了一个新的列,从该列中减去总运行金额为500万美元。 从$ 0的总运行额开始,我会得到一个负数,直到总运行额大于预算增量500万美元,然后再给我一个正数。 当它达到这个正数时,运行总额将是$ 5 + mil,但我想要的是$ 490万。 (当它达到正数时,我会在预算增量中增加500万美元。我需要提取前一个(最后一个)负数。
这是带注释的图片:
这是我到目前为止的代码:
Private Sub CommandButton2_Click()
Dim number_of_rows As Long
Dim budget_increment As Long
Dim rng_data As Range
Dim prev_visible_row As Object
number_of_rows = Cells(Rows.Count, 5).End(xlUp).Row
Set rng_data = Range("I2:I" & number_of_rows)
budget_increment = 5000000
For i = 180 To number_of_rows
Range("I" & i & ":I" & i) = Range("H" & i & ":H" & i) - budget_increment
If Range("I" & i).Value > 0 Then
budget_increment = budget_increment + 5000000
'find out how to copy the last visible row and paste onto new sheet my attempt at solving this (did not work):
AutoFilter.Range.Offset(i - 1).SpecialCells(xlCellTypeLastCell).Cells.Copy
'Sheets("Sheet3").Range("T1").Select
'Sheets("Sheet3").Paste
End If
Next
Application.ScreenUpdating = True
End Sub
尝试将其添加到顶级Dim inc, counter As Integer: counter = 0
并将If Range("I" & i).Value > 0 Then
更改为:
If Range("I" & i).Value < Range("I" & (i-1)).Value Then
For inc = 1 to 999
If Rows(i-inc).RowHeight > 0 And Range("I" & (i-inc)).Value < 0 Then
Sheets("Sheet3").Range("A” & (counter + 1) & ":Z" & (counter + 1)).Value = Range("A" & (i-inc) & ":Z" & (i-inc)).Value ' Or something
counter = counter + 1
Exit For
End If
Next
End If
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.