Livin404
Well-known Member
- Joined
- Jan 7, 2019
- Messages
- 743
- Office Version
- 365
- 2019
- Platform
- Windows
Greetings, Thanks to Mr. Rick Rothstein from this site, I have a VBA that will provide the current year. It will insert a 20 in front of the the last three days of the Julian Year in Columns G and E. However, my purpose is to subtract G from E to get the total days in Column I. Since Column E will never be in the past, we need to concern ourselves with Column G. Quite simply if G is greater than E then I need to have something written in the code so Column G is less than Column E. For example Column E has a value of 355 and Column G has a value of 027, the code will put a 20 in front of 355 for 20355. I need the code to recognize that a 21 needs to be added in front of 027 for 21027. Only the year will be adjust by one if necessary. Later in the year it would be fine until we get to the end of next year. I think it definitely need an "Else" statement in there someplace. I provide an image as well as my current VBA. Thank you,
VBA Code:
Sub Full_Julian_Date()
With Range("G2", Range("G" & Rows.Count).End(xlUp))
.Value = Evaluate(Replace("IF(LEN(@)=3,TEXT(NOW(),""yy"")&@,@)", "@", .Address))
With Range("E2", Range("E" & Rows.Count).End(xlUp))
.Value = Evaluate(Replace("IF(LEN(@)=3,TEXT(NOW(),""yy"")&@,@)", "@", .Address))
End With
End With
End Sub
Last edited: