首页 文章

用于复制粘贴的Vba代码

提问于
浏览
0

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

1 回答

  • 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
    

相关问题