Page 1 of 1

ActiveCell.value+1 not worked if cell is date.

Posted: 13 Apr 2019, 22:27
by hyaray
in ahk, "xl.ActiveCell.Value := xl.ActiveCell.Value + 1" not worked if cell is date.
in VBE, "activeCell = activeCell + 1" can deal both num and date.
so is Ahk has a similar simple method can deal both number and date?? :xmas: :xmas:
I see xl.ActiveCell.Value(11) has mor info By XML,
I don't know is neccessary to deal XML and how to do :crazy:
Thanks very much!!!

Re: ActiveCell.value+1 not worked if cell is date.

Posted: 14 Apr 2019, 04:40
by Odlanir
This works for me:

Code: Select all

oExcel.ActiveCell.NumberFormat := "########"
oExcel.ActiveCell.value := oExcel.ActiveCell.value + 1
oExcel.ActiveCell.NumberFormat := "gg/MM/aaaa"  ; European date
;~ or
;~ oExcel.ActiveCell.NumberFormat := "MM/dd/yyyy" ; USA date ( I think )

Re: ActiveCell.value+1 not worked if cell is date.

Posted: 14 Apr 2019, 05:16
by Klarion
How about to use CDate function of VBA ? though I have never used it at AHK

Re: ActiveCell.value+1 not worked if cell is date.

Posted: 14 Apr 2019, 11:22
by hyaray
Odlanir wrote:
14 Apr 2019, 04:40
This works for me:

Code: Select all

oExcel.ActiveCell.NumberFormat := "########"
oExcel.ActiveCell.value := oExcel.ActiveCell.value + 1
oExcel.ActiveCell.NumberFormat := "gg/MM/aaaa"  ; European date
;~ or
;~ oExcel.ActiveCell.NumberFormat := "MM/dd/yyyy" ; USA date ( I think )
this can work well for date, thanks!! :xmas: :xmas: