Friday, 25 October 2013

Excel Macro to convert the data type of cell value

Sub conversion()

'We can convert the given variable in any desired format
' For example we we have a string as 09-jan-2013, we can convert it into date as mentioned below

date1 = CDate("09-jan-2013")
MsgBox "Data type of date1 is " & TypeName(date1)

'If the input to cdate function is not a valid date, type mismatch error will occur
'Similarly you can convert the string into integer, float ect
MsgBox CInt("243.6 ")

'To convert the number into string, you can use cstr function
no = 2344
MsgBox CStr(no)

End Sub


What do you think on above excel macro topic? Please provide your input, comments, questions on excel macro. I will try to reply as soon as possible. I value your opinion on Excel Macros.

No comments:

Post a Comment

Popular Posts

Search This Blog