Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 264
  • Last Modified:

Update cell in date column to a new date based on data in other cells

Column G is a date column that show the last time a chapter was updated.

I would like the date in Column G to be automatically updated to a static date (example of format: "15 NOV 14") if the following criteria is met:
If Column I, Column N, Column S, Column X, Column AC OR Column AH = "NEW" or "REVISED"
Otherwise, the pre-existing date in Column G is to remain intact and unchanged.

I've attached a sample spreadsheet.

Thanks,
Andrea
LastRevisionDateUpdate-sample.xlsm
0
Andreamary
Asked:
Andreamary
  • 3
1 Solution
 
Glenn RayExcel VBA DeveloperCommented:
The dates in your example workbook are static dates (i.e, constants) right now.  Would these be formulas usually?  If not, what should the new date be converted to?  Today's date?  Another calculated date based on other data?

A Worksheet_Change event should handle this, but will wait to hear clarification from you.

Regards,
-Glenn
0
 
Glenn RayExcel VBA DeveloperCommented:
Just as an example, here is a Worksheet_Change event that would change the Last Revision Date value in column G to today's date if any of the above-mentioned columns were to be changed.  
Option Explicit
Dim rng As Range
Dim cl As Object
Dim boolChange As Boolean
Dim x As Integer
Private Sub Worksheet_Change(ByVal Target As Range)
    If boolChange Then
        boolChange = False
        Exit Sub
    End If
    Set rng = Range("G2", Range("G2").End(xlDown))
    For Each cl In rng
        For x = 2 To 27 Step 5
            If cl.Offset(0, x) = "New" Or cl.Offset(0, x) = "Revised" Then
                boolChange = True
                cl.Value = Format(Now(), "dd-mmm-yy")
                Exit For
            End If
        Next x
    Next cl
    boolChange = False
End Sub

Open in new window


This code would be inserted into the "Book_Prod_Sept2014" sheet object in the VBA Project.  I've attached a modified version of your file that shows this.  I had to replicate your Data Validation range (TypeChange1) on another sheet to test.

Regards,
-Glenn
EE-LastRevisionDateUpdate-sample.xlsm
0
 
AndreamaryAuthor Commented:
Terrific, Glenn...the only modification I made was to line 16 (as shown below) since we use the same date for all changes within a cycle (and not the actual date the change is done on). So for each cycle, I'll update the code with the new 'static' date to be used.

cl.Value = Format("15-Nov-14", "dd-mmm-yy")

Thanks so much!

Cheers,
Andrea
0
 
Glenn RayExcel VBA DeveloperCommented:
You're welcome.  
-Glenn
0

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now