简体   繁体   中英

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) ie 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) .

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM