'why changes date format after splitting string to array vba
When I split a string of dates separate by space the format goes from dd:mm:yyyy to mm:dd:yyyy with some of items
before split:
13-04-2022
12-04-2022
11-04-2022
10-04-2022
09-04-2022
08-04-2022
07-04-2022
06-04-2022
05-04-2022
04-04-2022
03-04-2022
02-04-2022
01-04-2022
31-03-2022
30-03-2022
after split:
13-04-2022
4-12-2022
4-11-2022
4-10-2022
4-9-2022
4-8-2022
4-7-2022
4-6-2022
4-5-2022
4-4-2022
4-3-2022
4-2-2022
4-1-2022
31-03-2022
30-03-2022
Dim dateinput() As String
dateinput = Split(html.getElementById("pagecontent_Onbalansprijs_ddlDateSelection").innerText)
Dim item As Variant
i = 1
For Each item In dateinput()
Range("F" & i).Value = item
i = i + 1
Next item
Solution 1:[1]
Convert your text dates to true Date values:
Range("F" & i).Value = DateSerial(Mid(item, 7), Mid(item, 4, 2), Mid(item, 1, 2))
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Gustav |
