Click here to Skip to main content
15,884,099 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello everybody.
i m facing what i suppose being an excel bug. below issue code
Dim QuestoBook As Workbook
Set QuestoBook = ActiveWorkbook

Application.EnableEvents = False
QuestoBook.Sheets(1).Range("E6").Value = SourceSheet.Range("E2").Value
QuestoBook.Sheets(1).Range("E6").Value = CDate(QuestoBook.Sheets(1).Range("E6").Value)

QuestoBook.Sheets(1).Range("F6").Value = SourceSheet.Range("E" & UltimaRiga).Value
QuestoBook.Sheets(1).Range("F6").Value = CDate(QuestoBook.Sheets(1).Range("F6").Value)


Application.EnableEvents = True


ranges E6 and F6 value comes from external source (a table).
source date value are correctly formatted as date dd/mm/yyyy. however the destination value format reverse mm and dd (mm/dd)

What I have tried:

i tried to change the format once or twice but nothing change
QuestoBook.Sheets(1).Range("E6").NumberFormat = "mm/dd/yyyy"
QuestoBook.Sheets(1).Range("E6").NumberFormat = "dd/mm/yyyy"

excel ,however, identify derstination ranges value as date

MsgBox IsDate(QuestoBook.Sheets(1).Range("F6").Value)

always return true either for e6 and f6
Posted
Updated 2-May-22 23:16pm
Comments
Richard MacCutchan 1-May-22 8:04am    
What is contained in SourceSheet.Range("E2")?
And why are you copying the original value to E6, and then converting it?
QuestoBook.Sheets(1).Range("E6").Value = SourceSheet.Range("E2").Value
QuestoBook.Sheets(1).Range("E6").Value = CDate(QuestoBook.Sheets(1).Range("E6").Value)

Instead of
QuestoBook.Sheets(1).Range("E6").Value = CDate(SourceSheet.Range("E2").Value)

1 solution

I found a way around, instead of trasfer the value only from source to destination, i transfer the fromatting as well with this

Questbook.range(e6).Numberformat=source.range(e6).numberformat.
It works
Thanks
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900