Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

So, it is rather strange but this is what is happening. In my code I have the following line:

tbl_Input.Cells(46 + (l_position - 1) * L_SIZE_BA, 12) = tbl_Input.Cells(46 + (l_position - 2) * L_SIZE_BA, 12)

which is supposed to simply take the value of tbl_Input.Cells(a,b) and put it in tbl_Input.Cells(c,d). However, the value of Cells(a,b) is "06.01.2016" and when I run the code I get "07.01.2020".

If I take the text property like this, I get what I want correctly:

tbl_Input.Cells(46 + (l_position - 1) * L_SIZE_BA, 12) = tbl_Input.Cells(46 + (l_position - 2) * L_SIZE_BA, 12).Text

My question is like: Why do I get the 07.01.2020 in first place, when I am not writing .Text or .Value?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
211 views
Welcome To Ask or Share your Answers For Others

1 Answer

About a year later, just checking the questions in StackOverflow, the answer of this one is really obvious - I was probably having ThisWorkbook.Date1904 = True.

It gives exactly 4 years and a day difference, whenever you are copying something.

This is how to replicate it:

Public Sub TestMe()

    ThisWorkbook.Date1904 = True
    Cells(1, 1) = Date
    Cells(2, 1) = Cells(1, 1)
    ThisWorkbook.Date1904 = False

End Sub

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...