danovkos
05-11-2016, 04:14 AM
Hi
I have this code and i dont know, why, when importing data from txt file with this code to my excel sheet, it return numbers with decimal as text . Whole numbers are OK, but decimal numbers are as text.
I tried multiply variable with 1 also convert it with Abs(CDec(strTemp)) but i was not succesfull.
What i want is, that after importing data from txt file to sheet it will every number as number. Now only whole numbers are correct. So e.g. (number 1400 its OK, 345 its ok...), But number with decimal are not (1050,50 and 145,45 and.... there are as text)
I tried googled, but i was not succsessfull.
Pls. any suggestion how can i do it?
thx a lot
Dim a As Variant, b As Variant
Dim ws As Worksheet
Dim lngCounter As Long
Dim x As Long
Dim strTemp
Dim LastColumn As Long
Dim LastRow As Long
Dim Cesta As String
Dim Subor As String
Dim oFS As Object
Dim strFilename As String
Set ws = Workbooks(PrehladyNAMEVp).Worksheets("zrkadlo")
Workbooks(MyVP).Worksheets("mirror").Range("AZ4:BH10000").ClearContents
Range("A4").Select
Cesta = path1 & "path2"
Set oFS = CreateObject("Scripting.FileSystemObject")
Subor = "SudnePoplVRAT.txt"
Open Cesta & Subor For Input As #1
lngCounter = 1
ReDim b(1 To 8, 1 To 1)
Do While (EOF(1) = False)
lngCounter = lngCounter + 1
ReDim Preserve b(1 To 8, 1 To lngCounter)
Line Input #1, strTemp
a = Split(strTemp, vbTab)
For x = 0 To UBound(a)
If IsNumeric(a(x)) Then
a(x) = Abs(CDec(a(x))) * 1
End If
b(x + 1, lngCounter) = a(x)
' If IsNumeric(b) = True Then
' If IsNumeric(a(x)) = True Then
' a(x) = a(x) * 1
' End If
Next x
Loop
Close #1
ws.Cells(1, 52).Resize(UBound(b, 2), UBound(b, 1)).Value = WorksheetFunction.Transpose(b)
I have this code and i dont know, why, when importing data from txt file with this code to my excel sheet, it return numbers with decimal as text . Whole numbers are OK, but decimal numbers are as text.
I tried multiply variable with 1 also convert it with Abs(CDec(strTemp)) but i was not succesfull.
What i want is, that after importing data from txt file to sheet it will every number as number. Now only whole numbers are correct. So e.g. (number 1400 its OK, 345 its ok...), But number with decimal are not (1050,50 and 145,45 and.... there are as text)
I tried googled, but i was not succsessfull.
Pls. any suggestion how can i do it?
thx a lot
Dim a As Variant, b As Variant
Dim ws As Worksheet
Dim lngCounter As Long
Dim x As Long
Dim strTemp
Dim LastColumn As Long
Dim LastRow As Long
Dim Cesta As String
Dim Subor As String
Dim oFS As Object
Dim strFilename As String
Set ws = Workbooks(PrehladyNAMEVp).Worksheets("zrkadlo")
Workbooks(MyVP).Worksheets("mirror").Range("AZ4:BH10000").ClearContents
Range("A4").Select
Cesta = path1 & "path2"
Set oFS = CreateObject("Scripting.FileSystemObject")
Subor = "SudnePoplVRAT.txt"
Open Cesta & Subor For Input As #1
lngCounter = 1
ReDim b(1 To 8, 1 To 1)
Do While (EOF(1) = False)
lngCounter = lngCounter + 1
ReDim Preserve b(1 To 8, 1 To lngCounter)
Line Input #1, strTemp
a = Split(strTemp, vbTab)
For x = 0 To UBound(a)
If IsNumeric(a(x)) Then
a(x) = Abs(CDec(a(x))) * 1
End If
b(x + 1, lngCounter) = a(x)
' If IsNumeric(b) = True Then
' If IsNumeric(a(x)) = True Then
' a(x) = a(x) * 1
' End If
Next x
Loop
Close #1
ws.Cells(1, 52).Resize(UBound(b, 2), UBound(b, 1)).Value = WorksheetFunction.Transpose(b)