Excel VBA fill date as "General" in cell

Copper Contributor

For example, I need to a cell EXCATLY like this picture. Format must be "General". No ' allowed

The reason is I do not know the capture logic of another application, so I have to strictly follow a previous input pattern

When I use VBA cells(x,y).value = "02/01/2022", it autocorrect to Date format "2022/2/1" (based on date format of my system)

I have figured the following way:

(1) cells(x.y).formula = "=02/01/2022"

(2) copy then paste value with VBA

It will give me what I want, but copy paste within VBA is such a bad code

Any other solutions? An ideal solution is do not turn off/on auto correct in VBA

Many thanks!!!


1 Reply

Hi @qazzzlyt,


I tested this code and I think this will give you the result you need


With Cells(x, y)
    .Value = "02/01/2022"
    .NumberFormat = "General"
End With