Function = TEXT (cell; "hh: mm") Excel Visual basic

0

Dear, I need to make a macro emulating the function = TEXT () of EXCEL in vb.

The idea is that by having cells with hours (7:55) the function vb transforms me to 07:55. Usually for this I use = TEXT (cell, "hh: mm"), this transforms it. I need to take that function to visual basic but it does not work for me with the following code:

Sub cambiarFormatohhmm()
Dim celda As Range

    For Each celda In Selection
        celda.Value = Texto(celda,"hh:mm")
    Next

End Sub

Any ideas?

    
asked by Esteban Jaramillo 06.07.2016 в 23:51
source

2 answers

2

Try changing the for line so it looks like this:

Sub cambiarFormatohhmm()
Dim celda As Range

    For Each celda In Selection
        cell.NumberFormat = "hh:mm"
    Next

End Sub
    
answered by 07.07.2016 / 09:12
source
-1
Sub cambiarFormatohhmm()
Dim celda As Range

    For Each celda In Selection
        celda.Value = Format(celda,"hh:mm")
    Next

End Sub
    
answered by 12.11.2016 в 18:46