Forum Discussion

doit_2729's avatar
doit_2729
Copper Contributor
May 29, 2022
Solved

Copy and paste row data based on cell value with date criteria

I have the situation where i would like to copy data based on cell value in Column 1 where the row data should be copy row 13 to the below log for the respectively date to track our ripening log.   ...
  • HansVogelaar's avatar
    May 29, 2022

    doit_2729 

    Here you go:

    Private Sub CommandButton1_Click()
        Dim r As Long
        On Error Resume Next
        r = Evaluate("MATCH(1,(A16:A1000=""4A"")*(B16:B1000=TODAY()),0)")
        On Error GoTo 0
        If r = 0 Then
            MsgBox "Combination of Room 4A and today's date not found"
        Else
            Range("C" & r + 15).Resize(1, 13).Value = Range("C13").Resize(1, 13).Value
        End If
    End Sub
    
    Private Sub CommandButton2_Click()
        Dim r As Long
        On Error Resume Next
        r = Evaluate("MATCH(1,(A16:A1000=""4B"")*(B16:B1000=TODAY()),0)")
        On Error GoTo 0
        If r = 0 Then
            MsgBox "Combination of Room 4B and today's date not found"
        Else
            Range("C" & r + 15).Resize(1, 13).Value = Range("C14").Resize(1, 13).Value
        End If
    End Sub

Resources