ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Import Hours as Text (https://www.excelbanter.com/excel-programming/444777-import-hours-text.html)

If[_3_]

Import Hours as Text
 

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




GS[_2_]

Import Hours as Text
 
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 = "@")

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc




All times are GMT +1. The time now is 11:53 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com