Automating episode numbers when date changes

MariahCab

New Member
Joined
Mar 27, 2024
Messages
10
Office Version
  1. 365
Platform
  1. Windows
I am needing a formula to update the episode number when the dates change in the start of episode and start of next episode columns change.
If there is also a way to automate those to change as the dates occur that would also be GREAT

I appreciate any help!

D2 E2 F2 G2 H2
Start of careStart of EpisodeEpisode #Start of next episodeNext Episode #
1/10/243/10/2465/9/247
10/3/231/1/2433/31/244
12/5/233/4/2426/2/243
10/18/231/15/2424/14/243
3/19/243/19/2416/17/242
2/29/242/29/2415/29/242
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
The easiest way is
(mrexcel).xlsm
ABCDE
16Start of careStart of EpisodeEpisode #Start of next episodeNext Episode #
171/10/20243/10/202465/9/20247
1810/3/20231/1/202433/31/20244
1912/5/20233/4/202426/2/20243
2010/18/20231/15/202424/14/20243
213/19/20243/19/202416/17/20242
222/29/20242/29/202415/29/20242
23 
Sheet1
Cell Formulas
RangeFormula
E17:E23E17=IF(D17="","",C17+1)


if you will notice.. simply ading the simple formula to the last column will do what you are asking
I'm almost positive there are other critieria that hasnt been mentioned.. but as requested...
 
Upvote 0
Solution
if you are wanting the episode date to advance one based on ANY change
then a vba routine note: (this must be set as a worksheet change)

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim bRng As Range
Dim bLR As Long

'2
bLR = Cells(Rows.Count, 4).End(xlUp).Row
Set bRng = Range("d2:d" & bLR)

'3
If Not Intersect(Target, bRng) Is Nothing Then
Range("e" & Target.Row).Value = 1 + Range("c" & Target.Row).Value
End If
End Sub

this will auto advance the episode number in column e when the date changes in column d

here is how it works
the first part defines the environment

the second part defines the variables (counts the number of rows to consider, and sets the range)

the third part checks to see if anything changes in column d then advances the count in column e

(mrexcel).xlsm
ABCDE
1Start of careStart of EpisodeEpisode #Start of next episodeNext Episode #
21/10/20243/10/202465/9/20247
310/3/20231/1/202433/31/20244
412/5/20233/4/202426/2/2024
510/18/20231/15/202424/14/2024
63/19/20243/19/202416/17/2024
72/29/20242/29/202415/29/2024
Sheet2
 
Upvote 0
if you want it to work on both columns b/c and d/e please let me know
 
Upvote 0
the worksheet change can be done
by opening the VBA editor (alt f11)
double clicking the sheet
then selecting Worksheet from the first drop down box(at the top of the vba code window)
and Change in the second drop down box (at the top of the vba code window)
then pasting the vba code provided
 
Upvote 0
You are welcome
Glad I could help

you were the first person I helped :)
 
Upvote 1

Forum statistics

Threads
1,223,239
Messages
6,170,947
Members
452,368
Latest member
jayp2104

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