Forum Discussion
Ghulampopal
Oct 02, 2022Copper Contributor
If Statement that paste/freezes another cell
My file links an online source for daily Gold Prices. I need an if statement, where if I enter a date in a certain cell (ie, cell A1), then the calculated Daily Gold Price per Gram in cell A2, sh...
HansVogelaar
Oct 15, 2022MVP
Will cell B11 be edited by the user or does it contain a formula?
Ghulampopal
Oct 15, 2022Copper Contributor
It contains a sum formula from another column.
- GhulampopalOct 16, 2022Copper ContributorHans thanks again, worked perfectly.
- HansVogelaarOct 15, 2022MVP
Thanks. Try this version:
Private Sub Worksheet_Change(ByVal Target As Range) If Not Intersect(Range("B2"), Target) Is Nothing Then Application.EnableEvents = False If Range("B2").Value <> "" Then Range("E9").Value = Range("E9").Value Range("G9").Value = Range("G9").Value Else Range("E9").Formula = "='Live Gold & Silver Prices'!$J$2" Range("G9").Formula = "='Live Gold & Silver Prices'!$J$3" End If Application.EnableEvents = True End If If Not Intersect(Range("J:J"), Target) Is Nothing Then Application.EnableEvents = False If Range("B11").Value > 0 Then Range("B3").Value = "Not fully paid" Else Range("B3").Value = Date End If Application.EnableEvents = True End If End Sub
- GhulampopalOct 15, 2022Copper ContributorThe new request should have no effect on the previous request/code.
To give context, the date inserted in B2 (which freezes the gold/silver prices) is the date the user inserts when he/she has completed their cost analysis.
The new request/code for B3 is a date generated when the last payment has been paid.
Further detail on the new request, the user inserts all payments paid in column J, the total sum is captured in B11.
When B11 is above $0, B3 should display “Not Fully Paid”.
When B11 is equal to or less than $0, B3 should display that day’s date & should frozen, unless B11 goes above $0 again.
Hope it was clear, please let me know if you need further clarification. - HansVogelaarOct 15, 2022MVP
Do you want to react each time a cell in that column is changed, or only when B2 is changed?