VBA Code:
Sub func2()
'Define variables
Dim time1 As Date
Dim time2 As Date
Dim time3 As Date
Dim time3Value As Double
Dim targetFinishTime As Date
Dim allocatedTaktTime As Date
Dim targetTime As Date
Dim breakTime As Date
Dim lunchTime As Date
allocatedTaktTime = Range("P6").Value
time1 = TimeValue("06:10:00 AM")
time2 = TimeValue("09:15:00 AM")
time3 = TimeValue("12:00:00 PM")
time3Value = CDbl(time3)
breakTime = Range("D7").Value
lunchTime = Range("D8").Value
targetTime = time1 + allocatedTaktTime
If targetTime >= time1 And targetTime <= time2 Then
Dim searchRange As Range
Dim foundCell As Range
Dim followingRow As Range
Dim foundCell2 As Range
Dim followingRow2 As Range
Set searchRange = ThisWorkbook.Sheets("Sheet1").UsedRange
Set foundCell = searchRange.Find(time3Value, LookIn:=xlValues)
If Not foundCell Is Nothing Then
MsgBox ("Nothing")
Else
MsgBox ("It works")
End If
foundCell.Offset(1, 0).Range("A:BO").Copy
Range("12:12").Insert Shift:=xlDown
MsgBox Format(Range("E13").Value, "hh:mm:ss AM/PM")
MsgBox (Range("E14").Value)
MsgBox (time3Value)
End If
End Sub
The problem is towards the bottom
VBA Code:
foundCell.Offset(1, 0).Range("A:BO").Copy
What I'm trying to do is copying the row A15:BO15 and insert it after row 12.