所以我在VB工作,我遇到了一个看似简单的问题...... 我不能为我的生活弄清楚如何添加时间戳。
因此,当前代码从工作(a)工作表中获取当前工作表中的行。然后它从A列中抓取任何内容,并表示已完成。一旦找到“已完成”的实例,它就会抓取整行(禁止为空)并将其放入最近空白位置的已完成(d)工作表中...
我想要做的是......一旦将它放在已完成的工作表中,我还想在其刚刚粘贴的行的末尾添加另一个单元格,并仅为该日添加时间戳。意思是如果它在另一天打开,我不希望这个日期改变。
有什么想法吗?
Dim z As Long
Dim a As Worksheet, b As Worksheet, c As Worksheet, d As Worksheet
Set a = ThisWorkbook.Worksheets("Working")
Set b = ThisWorkbook.Worksheets("Peer Review")
Set c = ThisWorkbook.Worksheets("Waiting to Push")
Set d = ThisWorkbook.Worksheets("Completed")
z = 2
For z = a.Cells(a.Rows.Count, "A").End(xlUp).Row To 2 Step -1
If a.Cells(z, "A").Value2 <> vbNullString Then
Select Case UCase(a.Cells(z, "A").Value2)
Case "WORKING"
Case "PEER"
b.Rows(b.Cells(b.Rows.Count, "A").End(xlUp).Row + 1).Value2 = a.Rows(z).Value2
a.Rows(z).Delete
Case "WAITING"
c.Rows(c.Cells(c.Rows.Count, "A").End(xlUp).Row + 1).Value2 = a.Rows(z).Value2
a.Rows(z).Delete
Case "COMPLETED"
d.Rows(d.Cells(d.Rows.Count, "A").End(xlUp).Row + 1).Value2 = a.Rows(z).Value2
a.Rows(z).Delete
Case Else
End Select
End If
Next z
For z = b.Cells(b.Rows.Count, "A").End(xlUp).Row To 2 Step -1
If b.Cells(z, "A").Value2 <> vbNullString Then
Select Case UCase(b.Cells(z, "A").Value2)
Case "WORKING"
Case "PEER"
Case "WAITING"
c.Rows(c.Cells(c.Rows.Count, "A").End(xlUp).Row + 1).Value2 = b.Rows(z).Value2
b.Rows(z).Delete
Case "COMPLETED"
d.Rows(d.Cells(d.Rows.Count, "A").End(xlUp).Row + 1).Value2 = b.Rows(z).Value2
b.Rows(z).Delete
Case Else
End Select
End If
Next z
For z = c.Cells(c.Rows.Count, "A").End(xlUp).Row To 2 Step -1
If c.Cells(z, "A").Value2 <> vbNullString Then
Select Case UCase(c.Cells(z, "A").Value2)
Case "WORKING"
Case "PEER"
b.Rows(b.Cells(b.Rows.Count, "A").End(xlUp).Row + 1).Value2 = c.Rows(z).Value2
c.Rows(z).Delete
Case "WAITING"
Case "COMPLETED"
d.Rows(d.Cells(d.Rows.Count, "A").End(xlUp).Row + 1).Value2 = c.Rows(z).Value2
c.Rows(z).Delete
Case Else
End Select
End If
Next z
End Sub