IF Blank Range of cells

rbolinsky

New Member
Joined
Feb 15, 2021
Messages
12
Office Version
  1. 365
Platform
  1. Windows
So I need to populate today's date in Cell A4 based off any value that may be manually entered in cell b4, c4, d4, e4. So if B4 had $2131, A4 would get today's date populated. However if B4 had the same $2131 and C4 had $2344 then it would take the date that C4 gained the value. So it would always reflect the date last paid and not a moving target. Any ideas?

What I want is the last paid date of an incentive bonus. Picture for reference.

1648155958267.png
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Hello,

First set the format of B4:E4 as currency - do not type in the "$" sign or Excel reads it as text, not a number.

Press Alt F11 and paste the code below.

VBA Code:
Sub InsertDate()
    If Range("C4").Value = 0 Then 'If C4 is empty - it will do this bit
    Range("A4").Value = "=TODAY()" 'Inserts todays date
    Range("A4").Copy 'Copies the cell A4
    Range("A4").Select 'Pastes the value in A4, so it does not automatically update
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Else
    If Range("D4").Value = 0 And Range("C4").Value > Range("B4").Value Then 'If D4 is empty AND C4 is greater than B4 - it will do this bit
    Range("A4").Value = "=TODAY()"
    Range("A4").Copy
    Range("A4").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Else
    If Range("E4").Value = 0 And Range("D4").Value > Range("C4").Value Then
    Range("A4").Value = "=TODAY()"
    Range("A4").Copy
    Range("A4").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Else
    If Range("E4").Value > Range("D4").Value Then
    Range("A4").Value = "=TODAY()"
    Range("A4").Copy
    Range("A4").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    End If
    End If
    End If
    End If
    Application.CutCopyMode = False
End Sub

Now right click on the sheet tab and select View Code; and paste the code below

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address = "$B$4" Then 'when each cell changes it calls the code above
        Call InsertDate
    End If
    If Target.Address = "$C$4" Then
        Call InsertDate
    End If
    If Target.Address = "$D$4" Then
        Call InsertDate
    End If
    If Target.Address = "$E$4" Then
        Call InsertDate
    End If
End Sub

Jamie
 
Upvote 0

Forum statistics

Threads
1,215,009
Messages
6,122,674
Members
449,091
Latest member
peppernaut

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