Forum Discussion
Kasey_Vincent
Jul 25, 2019Copper Contributor
(Excel) Pulling date from another sheet, adding one week to it
I know I’m a little late to the party here, but Im trying to pull a date from a previous sheet and add it to the next sheet, while adding 7 days to the date. Is there a macro on how to do this? I’ve ...
- Jul 25, 2019
Okay, Never mind. I figured it out. It turns out it was a really simple formula after adding that macro for the PrevSheet object. All I had to do was add +7 to the end of it. I was way overthinking it. Maybe by leaving this here it will help someone else. My formula in the K1 field looks like this now:
=PrevSheet(K1)+7
And the macro as I said earlier was:
Function PrevSheet(RCell As Range)
Dim xIndex As Long
Application.Volatile
xIndex = RCell.Worksheet.Index
If xIndex > 1 Then _
PrevSheet = Worksheets(xIndex – 1).Range(RCell.Address)
End Function
Kasey_Vincent
Jul 25, 2019Copper Contributor
Okay, Never mind. I figured it out. It turns out it was a really simple formula after adding that macro for the PrevSheet object. All I had to do was add +7 to the end of it. I was way overthinking it. Maybe by leaving this here it will help someone else. My formula in the K1 field looks like this now:
=PrevSheet(K1)+7
And the macro as I said earlier was:
Function PrevSheet(RCell As Range)
Dim xIndex As Long
Application.Volatile
xIndex = RCell.Worksheet.Index
If xIndex > 1 Then _
PrevSheet = Worksheets(xIndex – 1).Range(RCell.Address)
End Function
JoshDavies820
Jul 06, 2023Copper Contributor
Even later to the party... I'm trying to do the same thing but my cell being B2. It seems to run into an error so wondering if you could help?