Tom
Tom

Reputation: 65

Change an excel formula cell into a vba macro

Please I need to change this formula:

=IF(VAL.EMPTY(K15);"";MAX(K15-Today();0))

This formula gives the difference between two dates:

1) i.e. K15: 30/10/2017

2) Today()

The maximum countdown stops at 0.

I need to transform this formula in a macro in order to insert this bit of code in a macro ran by Private Sub Worksheet_Change(ByVal Target As Range).

Upvotes: 0

Views: 58

Answers (1)

Satheesh K
Satheesh K

Reputation: 108

i hope the below code line should work, tested working fine for me.

 Sheet2.Range("M15:M38").Formula = "=IF(ISBLANK(K15),0,MAX(K15)-TODAY())"

too many arguments for IF function in your code. also you may use 0 instead of "" to keep a simple string of formula.

Upvotes: 1

Related Questions