我正在寻找一个按钮的帮助,我已经在单元格A1中获得了数据,一旦我在一天结束时我需要将其粘贴到另一个单元格中。
在单元格B1:B6我有星期一到星期六我想制作一个按钮将A1的数据复制到星期一我已经做了一个按钮来清除A1,当我在一天结束时准备好了第二天。
我需要按钮在每天结束时更新数据,并在第二天按下清除按钮后重新开始。
答案 0 :(得分:0)
这就是你想要的东西吗?
Sub CopyDataByDay()
Dim data As Range
Dim today As Date
Set data = ThisWorkbook.Worksheets(1).Range("A1")
today = Date
If (Weekday(today) = vbMonday) Then
ThisWorkbook.Worksheets(1).Range("B1") = data.Value
ElseIf (Weekday(today) = vbTuesday) Then
ThisWorkbook.Worksheets(1).Range("B2") = data.Value
ElseIf (Weekday(today) = vbWednesday) Then
ThisWorkbook.Worksheets(1).Range("B3") = data.Value
ElseIf (Weekday(today) = vbThursday) Then
ThisWorkbook.Worksheets(1).Range("B4") = data.Value
ElseIf (Weekday(today) = vbFriday) Then
ThisWorkbook.Worksheets(1).Range("B5") = data.Value
ElseIf (Weekday(today) = vbSaturday) Then
ThisWorkbook.Worksheets(1).Range("B6") = data.Value
End If
data.Value = ""
End Sub
答案 1 :(得分:0)
你可以试试这个:
Sub Main()
Dim IWeekday As Integer
IWeekday = Weekday(Date(), vbMonday)
With ThisWorkbook.Worksheets(1).Range("A1")
If IWeekday <> 7 Then .Offset(IWeekday -1, 1).Value = .Value
.ClearContents
End With
End Sub