-1
因此,在Excel Sheet1中我有一個用戶需要的信息列表(有一張圖片)在那裏我們有開始時間和執行時間。這些信息被傳遞給sheet3,我希望結束時間根據執行時間而改變。例如,如果用戶輸入開始時間= 1:00 pm並且執行時間= 30分鐘。我希望代碼在表格3 = 1:30 pm的最後時間。下面是當前代碼我有:我需要一段時間來改變用戶使用VBA輸入的內容
Sub findData()
Dim workflow As String
Dim finalrow As Integer
Dim i As Integer
With Sheets("Sheet1")
workflow = .Range("C5").Value
servergri = .Range("C9").Value
gridf = .Range("C9").Value
StartTime = .Range("c11").Value
End With
With Sheets("Sheet3")
finalrow = .Range("C" & Rows.Count).End(xlUp).Row
For i = 5 To finalrow
If .Cells(i, 3) = workflow And (.Cells(i, 4) = servergri Or .Cells(i, 5) = gridf) Then
.Rows(i).Insert
'Add new information to the new row.
'The new row number is still = i
.Cells(i, 3) = workflow
.Cells(i, 4) = servergri
.Cells(i, 6) = StartTime
.Cells(i, 3).Resize(2, 4).Interior.ColorIndex = 8
'If you only want to add one row then your should exit the loop
Exit For
End If
Next
End With
End Sub