VBA not working when IF formula is present

CoffeeBrew

New Member
Joined
Oct 31, 2021
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hi,

I just started using VBA with Excel and in this forum I found help in an old thread to create a static date when something was written in another cell.

If I connect this cell to the one in another sheet it keep working the way I want but as soon as I add and IF formula on it the static date of today won't print.
Could someone please help me figure it out?

I upload a test file for easier comprehension.

Thanks.

Test.xlsm
ABCD
5When I write this -->I would like to get this number with a static date on the other sheet
6If there is nothing here -->Blank and no date in the other sheet
723226
853615
93359
10223166
112316
126635198
132366
147337219
15263378
167731231
175236156
18223366
19113533
20133
Foglio1
Cell Formulas
RangeFormula
D7:D20D7=A7*B7


Test.xlsm
L
7
Foglio2

Test.xlsm
ABCDEFGH
2945531/10/2021<-- This should be the result
306631/10/2021
315631/10/2021
3215<-- This is what I get instead when I use a formula
339
3466
356
36198
376
38219
3978
40231
41156
4266
4333
44 
Foglio2
Cell Formulas
RangeFormula
B32:B44B32=IF(Foglio1!C8="","",Foglio1!D8)
 

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
This is the VBA code I am using:

Private Sub Worksheet_Change(ByVal Target As Range)

' Make sure only one cell updated
If Target.CountLarge > 1 Then Exit Sub

' Update date in column D if row>=3 and column>=5 (and not a blank entry)
If (Target.Row >= 29) And (Target.Column = 2) And (Target <> "") Then
Cells(Target.Row, "C") = Date
End If

End Sub
 
Upvote 0

Forum statistics

Threads
1,214,915
Messages
6,122,214
Members
449,074
Latest member
cancansova

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