When dropdown changes to specific text add date to a cell

Nick70

Active Member
Joined
Aug 20, 2013
Messages
299
Office Version
  1. 365
Platform
  1. Windows
Hi,

I have a range in sheet1 (range J2:J10) that has data validation, so each cell in this range has a dropdown which has 4 different text options: not started, started, ongoing, complete.

I would like to have a macro that if dropdown selection (in range J2:J10) is either 'started' or 'ongoing' then the corresponding cell in range N2:N10 is filled in with today's date.

For example if one selects 'started' or 'ongoing' in cell J4 then cell N4 will be filled in with today's date.
If one selects 'started' or 'ongoing' in cell J8 then cell N8 will be filled in with today's date and so on.

It is important that today's date that appears in range N2:N10 is a hardcoded date that does not change the following day (so it should not be formula (=today()).
Also if text not 'started' or 'complete' is selected in any cell in range J2:J10 then any text in corresponding cell in range N2:N10 must be deleted (so if there was a date this should be deleted).

What code can I use to do this?

Thanks,
Nix
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
How about
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
   If Target.CountLarge > 1 Then Exit Sub
   If Not Intersect(Target, Range("J2:J10")) Is Nothing Then
      Select Case Target
         Case "started", "ongoing"
            Target.Offset(, 4).Value = Date
         Case Else
            Target.Offset(, 4).Value = ""
      End Select
   End If
End Sub
This needs to go in the sheet module for the relevant sheet
 
Upvote 0
Solution
Great that is perfect.

It is doing exactly what I wanted.

Thanks,
Nic :)(y)
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0
It stops the code from running if more than one cell is changed.
 
Upvote 0

Forum statistics

Threads
1,215,054
Messages
6,122,893
Members
449,097
Latest member
dbomb1414

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