用于复制粘贴的Vba代码

时间:2018-02-20 04:44:42

标签: excel excel-vba vba

我需要有关vba代码逻辑语句的帮助 我有一个工作表1,其中c19是开始日期,d19是结束日期。 还有另一个工作表,其列f包含一系列日期。 我需要从列f中选择大于等于开始日期且小于等于结束日期的日期,然后复制粘贴工作表1中的日期,例如范围c25

1 个答案:

答案 0 :(得分:0)

这应该可以,但我保持输入范围只有F1到F12而不是整个F列

Sub copy_paste()

Dim cell As Range, paste_loc As Range

Set paste_loc = Range("C25") 'Output paste location

For Each cell In Range("F1:F12")    'Input range

    If cell.Value > Range("C19").Value And cell.Value < Range("C19").Value Then
        paste_loc = cell.Value
        Set paste_loc = paste_loc.Offset(1, 0)
    End If

Next cell


End Sub
相关问题