将范围指定为countifs excel vba的字符串

时间:2013-06-11 06:19:50

标签: string excel-vba range vba excel

我正在尝试为countifs提供变量输入,并且坚持如何执行以下操作。 如果有任何可行的方法,请告诉我。

 dumi = ".Range(.Cells(2, Submit_date), .Cells(lastrow, Submit_date))"
 i = Application.WorksheetFunction.CountIfs(dumi, ">=" & date1, _
 dumi, "<=" & date2)

我也试过了,

 dumi = .Range(.Cells(2, Submit_date), .Cells(lastrow, Submit_date))
      i = Application.WorksheetFunction.CountIfs(dumi, ">=" & date1, _
      .Range(.Cells(2, Submit_date), .Cells(lastrow, Submit_date)), "<=" & date2

但没有人工作..帮帮我

1 个答案:

答案 0 :(得分:0)

您可以使用类似的内容 - 我在Submit_datelastrow(以及两个日期)中添加了我自己的值,以查找在活动表上查看A1:A10的示例。< / p>

Dim date1 As Date
Dim date2 As Date
Dim rng1 As Range
Submit_date = 1
lastrow = 10
date1 = #6/2/2013#
date2 = #6/10/2013#
Set rng1 = Range(Cells(2, Submit_date), Cells(lastrow, Submit_date))
MsgBox Application.WorksheetFunction.CountIfs(rng1, ">=" & date1, rng1, "<=" & date2)