'VBA problem with type mismatch with add data
I would like to add another date next to the next one in the macro, i.e. if I have on G32 2021.01, I would like to add on H322021.02. However, my feature shows me the Type Mismatch here : *.Range("H32").Value = Format(Application.WorksheetFunction.EoMonth(DateAdd("m", 1, .Range("G32").Value), 0), "yyyy-mm")
*
With wbMe.Sheets("strona 5")
.Range("F32:H42").UnMerge
.Range("G32:G42").Copy
.Range("F32").PasteSpecial Paste:=xlPasteValues
.Range("H32:H42").Copy
.Range("G32:G32").PasteSpecial Paste:=xlPasteValues
.Range("H32:H42").ClearContents
.Range("H32").Value = Format(Application.WorksheetFunction.EoMonth(DateAdd("m", 1, .Range("G32").Value), 0), "yyyy-mm")
.Range("F32:H42").Merge
End With
Solution 1:[1]
Solution put instead
.Range("H32").Value = Format(Application.WorksheetFunction.EoMonth(DateAdd("m", 1, .Range("G32").Value), 0), "yyyy-mm") to
.Range("H32").Value = Format(DateAdd("m",1, Replace(.Range("G32"),".","-")), "yyyy-mm")
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 | Przemek Dabek |
