我正在编写一个脚本,如果数据重复为>3
,我可以对列中的数据进行计数,我将对其进行标记..
我的问题是我需要设置一个条件语句,我可以在 1个月的日期范围内计算数据。
示例输入文件::(mm / dd / yyyy)
Column A | Column B | Column C| Column D
023 | 1/2/2016 | |
023 | 1/3/2016 | |
023 | 1/4/2016 | |
024 | 2/1/2016 | |
024 | 3/1/2016 | |
024 | 4/1/2016 | |
示例输出文件:
Column A | Column B | Column C| Column D
023 | 1/2/2016 | |
023 | 1/3/2016 | |
023 | 1/4/2016 | 1 | 3
024 | 2/1/2016 | |
024 | 3/1/2016 | |
024 | 4/1/2016 | |
如果重复数据不在一个月范围内,则不会标记..
我希望代码 计算来自Column A
的数据(如果数据>> 3)以及来自{的所有数据的日期{1}}距离Column B
和Column D
一个月内的标记不是E
我的代码所做的 会计算来自Column B
的数据,如果数据为Column A
,则该数据将来自>3
和来自B列的最近日期的Column C
我的代码:
D
注意:
Dim i1 As Long, lastRow As Long, countRow As Long
lastRow = Sheet2.Range("T" & Rows.Count).End(xlUp).Row
'xDate = Sheet2.Range("C" & lastRow)
For i1 = 1 To lastRow
If countRow > 2 Then
countRow = Application.CountIf(Sheet2.Columns(20), Sheet2.Cells(i1, 20))
If countRow > 2 Then
If Not CBool(Application.CountIfs(Sheet2.Columns(20), Sheet2.Cells(i1, 20), _
Sheet2.Columns(85), ">" & Sheet2.Cells(i1, 85))) Then _
Sheet2.Cells(i1, 86).Resize(1, 2) = Array("1", "3")
End If
End If
Next i1
Column
A
B
C
代替它D
{ {1}} Column
T
CG
我不知道如何将它调整到一个月,我尝试过收藏,但对VBA来说还是新手,我不熟悉它,我不知道它是否已经知道了正确的事情..
答案 0 :(得分:1)
此输入......
生成了这个输出......
来自此代码...
i1
具体来说,使用工作表功能EDate将三个月添加到给定项目编号的第一个日期。
此外,缩短工作表函数CountIf用作循环计数器iLoop进展的列表大小。
另外,在您的代码段中,您使用il
作为循环计数器。很容易将此与var urls = [ 'http://a.com/fruits', 'http://a.com/cars', 'http://a.com/toys' ]
function getData(){
// get html and parse, return some data.
...
}
var data_set = '';
for (var i=0; i< urls.length ; i++){
data_set += getData(urls[i]);
}
// When get all data, render <------ How can I catch when?
res.render('some_page', { data : data_set });
混淆。 8)
答案 1 :(得分:1)
已编辑:仅按照最后OP的规格和公式更正保留代码
你可以试试这个
Sub sbFindDuplicatesInColumn_C3ter()
With ThisWorkbook.Worksheets("duplicates") '<~~ you should know what workbook and worksheet you are on!!
With .Range("T1").Resize(.Range("T" & .Rows.Count).End(xlUp).Row) ' the "base" column is column "T"
With .Offset(, 67) ' column "CI" is 67 columns away from column "T"
.FormulaR1C1 = "=IF(COUNTIFS(C20, RC20, C72,""<="" & EOMONTH(RC72,0), C72,"">="" & EOMONTH(RC72,-1)+1 )>2, IF(COUNTIFS(C20, RC20,C72,"">"" &RC72,C72,""<="" & EOMONTH(RC72,0))=0, 3 , """") , """")" ' substituted relative references with absolute ones : column "T" has index 20, column "BT" has index 72
.Value = .Value '<== if you want to get rid of formulas
End With
With .Offset(, 66) ' column "CH" is 66 columns away from column "T"
.FormulaR1C1 = "=IF(RC[1]>0, 1, """") " ' I left relative references since columnn "CH" is always one left of column "CG" as was for columns "A" and "B"
.Value = .Value '<== if you want to get rid of formulas
End With
End With
End With
End Sub