[RESOLVED] Converting from BVA to VB6
Hi I need to convert the format of two columns in excel. Time and Date. I recorded a macro and this is the BVA code I get.
Code:
Columns("B:B").Select
Selection.NumberFormat = "h:mm;@"
Columns("A:A").Select
Selection.NumberFormat = "m/d/yy;@"
Now I need to convert it to VB6. Can you help me? I try it several times but I could not get it. See below
Code:
'oXLsheet.Range(Columns).Select
oXLsheet.Columns("B:B").Select
oXLsheet.Columns.NumberFormat = "h:mm;@"
oXLsheet.Columns("A:A").Select
oXLsheet.Columns.NumberFormat = "m/d/yy;@"
Thanks
Re: Converting from BVA to VB6
Did you instanciate oXLsheet? Whats the rest of your code look like that opens the workbook? Any error messages and what does the cell format do if its not correct?
Re: Converting from BVA to VB6
The first step to take is remove .Select and Selection, so this:
Code:
Columns("B:B").Select
Selection.NumberFormat = "h:mm;@"
becomes this:
Code:
Columns("B:B").NumberFormat = "h:mm;@"
(this will work around your mistake - you didn't specify which Columns to set the NumberFormat on)
..and then, make it safe for VB by prefixing your sheet object, eg:
Code:
oXLsheet.Columns("B:B").NumberFormat = "h:mm;@"
Re: Converting from BVA to VB6
That did it. Thank you Si_The_Geek!