I have a SQL Query, which I want to use in VBA to load the data into Excel, the problem is that when the load is done the data in Excel is with the wrong type. For example, where it needs to be a date, it remains an integer, where an integer is a date. Is there any way to fix this? Example my query:
sql = " SELECT DATA, ITEM, COMPANY, SALES FROM SALES "
Advertisement
Answer
You will have to format cells as per date format. Also ensure that values are correct in your query output.
Sheet1.Range("A2", "A100").NumberFormat = "yyyy-mm-dd"