Hello, this is my first post here. I have followed & searched for a long time trying to learn. But I just can't seem to overcome this. The following code run from the ribbon. works fine. Applied to a button & the code in orange returns only 14 (January 14, 1900 as it is a date). Cell AF92 is a date (pay date) that I am trying to add 14 days to each time this code is run. Format in the cell is short form (45372, example for today) date. Button is located on "Timesheet" sheet. "Data Log" sheet is just a running copy of what a person entered on Timesheet for their personal history, then all is cleared on Timesheet for future manual input. All in same workbook. There may be other issues here, please advise to all, but my main concern is why in the world am i getting different results when applying to a button?
Rich (BB code):
Sub vba_copy_to_another_worksheet()
Dim orig_Rang As Range
Set orig_Rng = Selection
ActiveSheet.Unprotect "**"
Worksheets("Data Log").Unprotect "**"
Worksheets("Data Log").Range("F:F").EntireColumn.Insert
Worksheets("Data Log").Columns("E").Copy
Worksheets("Data Log").Columns("F").PasteSpecial xlPasteValues
Application.CutCopyMode = False
Dim s As Range
Worksheets("Timesheet").Range("J117:O117").Copy
Worksheets("Timesheet").Range("J112:O112").PasteSpecial xlPasteValues
Worksheets("Timesheet").Range("I7:AL20").ClearContents
Worksheets("Timesheet").Range("AF92").Value = Range("AF92").Value + 14
Worksheets("Data Log").Range("A41:C41").ClearContents
orig_Rng.Parent.Activate
orig_Rng.Select
Worksheets("Timesheet").Protect "**"
Worksheets("Data Log").Protect "**"
End Sub
Last edited by a moderator: