Insert Julian day in excel cell

buttergoose

New Member
Joined
Dec 19, 2023
Messages
5
Office Version
  1. 365
Platform
  1. Windows
Hello again,

Thanks to this sub I perfected the last code I needed help with. In short, for work we use excel to log events, this code populates my desired cells with date and time when the event cell is being filled in.
Has worked great, but now I want another cell to populate with the current Julian Day counting from 0-365 (ie: jan 27th = 27, feb 7th = 38 and so on).
I want this in single digit in the cell, only the day. I am unsure if "Julian day" is the proper term but that is what my work calls it and I hope you understand what I mean.
Below is the code that I've been using successfully

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count = 1 Then
If Not Intersect(Target, Columns("G")) Is Nothing Then
If Target.Row > 1 And Target.Offset(, 2) = "" Then
If Target.Offset(, -6) = "" Then
Target.Offset(, -6) = Date
Target.Offset(, -4) = Time
End If
End If
End If
End If
End Sub


So, I would like to have something like (hypothetically:): TargetOffset(, -3) = Julian Day

Thank you in advance!
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Try this:
VBA Code:
Target.Offset(, -3) = Date - DateSerial(Year(Date), 1, 1) + 1
 
Upvote 0

Forum statistics

Threads
1,224,568
Messages
6,179,572
Members
452,927
Latest member
whitfieldcraig

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top