Import Hours as Text

I

If

Hello,

I have this procedure that allows me to import another tab values ​​in
hours.
But I would like this data to be imported in text format.

---------------------------------------------------------------
Sub ImportCompensation()

Dim Nom As String, i As Long, j As Long
Sheets("Datas").Select
i = 3
With Sheets("Compensation")
Do While Cells(i, 1) <> ""
Nom = Cells(i, 1)
For j = 1 To .Range("A65536").End(xlUp).Row
If Nom = .Cells(j, 3) Then
Cells(i, 14) = .Cells(j, 5)
Cells(i, 15) = .Cells(j, 6)
Cells(i, 16) = .Cells(j, 7)
Exit For
End If
Next
i = i + 1
Loop
End With

End Sub
------------------------------------------------------



I found this procedure to transform one hour in text format.
------------------------------------------------------
ActiveCell.Formula = "=TEXT(A1,""hh"""" h """"mm"")"
------------------------------------------------------
But the formula remains in the cell and I'd rather get my cell value.
I would like to get for example 10 hours 10 minutes in text format (not
time format)



It's possible to import formatted text with my first procedure?


Thanks for your answer.

Yves
 
G

GS

If brought next idea :
Hello,

I have this procedure that allows me to import another tab values ​​in hours.
But I would like this data to be imported in text format.

---------------------------------------------------------------
Sub ImportCompensation()

Dim Nom As String, i As Long, j As Long
Sheets("Datas").Select
i = 3
With Sheets("Compensation")
Do While Cells(i, 1) <> ""
Nom = Cells(i, 1)
For j = 1 To .Range("A65536").End(xlUp).Row
If Nom = .Cells(j, 3) Then
Cells(i, 14) = .Cells(j, 5)
Cells(i, 15) = .Cells(j, 6)
Cells(i, 16) = .Cells(j, 7)
Exit For
End If
Next
i = i + 1
Loop
End With

End Sub
------------------------------------------------------



I found this procedure to transform one hour in text format.
------------------------------------------------------
ActiveCell.Formula = "=TEXT(A1,""hh"""" h """"mm"")"
------------------------------------------------------
But the formula remains in the cell and I'd rather get my cell value.
I would like to get for example 10 hours 10 minutes in text format (not time
format)



It's possible to import formatted text with my first procedure?


Thanks for your answer.

Yves

Look in online help for the Format() function and how you might
implement it here. Also, you'll want to change the target cell's number
format to text. (NumberFormat = "@")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top