本文介绍了根据其他列创建列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我之前用错误的方式问过问题.我已将其完全擦除并再次询问.

earlier I had asked question in wrong way.i have erased it completely and asking again.

假设有A,B,C列

c = A > B

一段时间后,假设 A2 中的值更改为20,现在 C2 将为 true

after some time, suppose value in A2 changes to 20 now C2 will be true

一段时间后,假设 A2 中的值现在更改为1, C2 将为 false

again after some time, suppose value in A2 changes to 1 now C2 will be false

我想添加另一列D,以便每当 C 列中单元格中的值第一次变成 true ,在 D 中的对应单元格,即 D2 是真实的,并且即使C列的 c2 单元格中的值不断变化,也应保持为true从真到假,反之亦然

I want to add another column D such that, whenever value in cell in column Cbecomes true ,for the first time, corresponding cell in D i.e D2 should be true,and it should remain true even if value in cell c2 in column C keep on changingfrom true to false and vice versa

与其他行相同

我希望我这次已经清楚地问过了.

I hope I have asked this time clearly.

修改2:实际问题

值全天都在变化,假设第5行和第6行中的值在一天中的某个时候是正确的

values in this column keep on changing throughout the day,lets say values in row number 5 and 6 was true at some point during the day

当我看到此数据时,该行在eod(一天结束)的值是false

when i see this data, at eod (end of the day) value in this rows is false

我想知道,cr3列中的值对于至少哪一次为真的行一天之内

为解决此问题,我想创建另一列,其中将包含此行的值为 true ,因为它们在一天中的某个时候其中的 true值

to solve this issue, i wanted to create another column which will containvalue as true for this rows, as at some point during the day they hadtrue value in them

推荐答案

在工作表模块中尝试以下代码:

Try this code in you sheet module:

Private Sub Worksheet_Calculate()

    'Declarations.
    Dim RngSource As Range
    Dim RngResult As Range
    Dim DblRow As Double

    'Setting RngSource as the first data cell of the third column.
    Set RngSource = Me.Range("C1")

    'Resetting RngSource as the whole continuous data of the third column .
    Set RngSource = Me.Range(RngSource, RngSource.End(xlDown))

    'Checking if the RngSource is full.
    If Excel.WorksheetFunction.CountBlank(RngSource) = 0 Then

        'Setting RngResult as the range offset of RngSource.
        Set RngResult = RngSource.Offset(0, 1)

        For DblRow = 1 To RngSource.Rows.Count
            RngResult.Cells(DblRow, 1).Value = ((RngResult.Cells(DblRow, 1).Value Or RngSource.Cells(DblRow, 1).Value) = True)
        Next

    End If

End Sub

这篇关于根据其他列创建列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 01:52