Dec 01 2022 03:01 AM - edited Dec 01 2022 03:04 AM
COLUMN | F | G | H | I | J | K | L | M |
HEADING | MATCH NO. | DATE | COMP. LEVEL | PLAYER | MATCH PTS | PLAYER Pts | COMPUTER Pts | WINNER |
DATA | 1 | EXPERT | Tom | 5 | 7 | 2 | Tom |
The above represents a section of a table that records a competitor's results against a computer.
I have successfuly managed to get all columns (except G) automatically filled once the scores in Col K and Col L are entered. But Col G is driving me mad!
1) I want the date to be Today() at the time that Col K and Col L are entered, BUT, if there is a already a date in the cell, I need that date to be left as it is.
2) I want to be able to put the formula into subsequent rows so that if Columns K and L are empty then the equivalent cell in Column G also remains empty.
I have tried many permutation of If, And, Or. IsBlank() and Isnumber(), but I cannot crack it. I thought I had, but then found that the following day the Today() overwrote earlier entries! Nightmare!
I would be so grateful for the solution, please!
Thank you...
Dec 01 2022 03:46 AM
There are two ways to do this:
For iterative calculation:
For a VBA solution:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range
Dim r As Long
If Not Intersect(Range("K2:L" & Rows.Count), Target) Is Nothing Then
Application.ScreenUpdating = False
Application.EnableEvents = False
For Each rng In Intersect(Range("K2:L" & Rows.Count), Target)
r = rng.Row
If Range("K" & r).Value <> "" And Range("L" & rng.Row).Value <> "" Then
Range("G" & rng.Row).Value = Date
Else
Range("G" & rng.Row).ClearContents
End If
Next rng
Application.EnableEvents = True
Application.ScreenUpdating = True
End If
End Sub
Dec 01 2022 08:14 AM
Dec 01 2022 11:56 AM
The formula will enter a date in G2 if you enter something in both K2 and L2 (and if you have enabled iterative calculation)
See the attached demo workbook.
Dec 01 2022 10:23 PM
SolutionDec 01 2022 10:23 PM
Solution