Laver punktum istedet for komma når jeg indsætter en txt fil i excel via VBA
Hej.Jeg har fundet / rettet i den code.
Den indsætter en txt fil i mit sheet. Problemet er at når tallet i denne txt fil er over 1. Laver den punktum istedet for komma, dette medføre at tallet bliver 10000 gange så stor som den rigtig komma værdi. De tal der er under 1 i filen er stadig "orginale" komma tal. Hvis jeg åbner txt direkte i Excel er alle tallene komma tal.
Kan du/I hjælpe mig.
Sub Example5()
Dim basebook As Workbook
Dim mybook As Workbook
Dim sourceRange As Range
Dim destrange As Range
Dim SourceRcount As Long
Dim N As Long
Dim rnum As Long
Dim MyPath As String
Dim SaveDriveDir As String
Dim FName As Variant
SaveDriveDir = CurDir
MyPath = "C:\"
ChDrive MyPath
ChDir MyPath
FName = Application.GetOpenFilename(filefilter:="Excel Files (*.*), *.*", _
MultiSelect:=True)
If IsArray(FName) Then
Application.ScreenUpdating = False
Set basebook = ThisWorkbook
For N = LBound(FName) To UBound(FName)
Set mybook = Workbooks.Open(FName(N))
rnum = LastRow(basebook.Worksheets(4)) + 1
Set sourceRange = mybook.Worksheets(1).Range("A1:J99999")
SourceRcount = sourceRange.Rows.Count
Set destrange = basebook.Worksheets(4).Cells(rnum, "A")
basebook.Worksheets(4).Cells(rnum, "D").Value = mybook.Name
' This will add the workbook name in column D if you want
sourceRange.Copy destrange
' Instead of this line you can use the code below to copy only the values
' With sourceRange
' Set destrange = basebook.Worksheets(1).Cells(rnum, "A"). _
' Resize(.Rows.Count, .Columns.Count)
' End With
' destrange.Value = sourceRange.Value
mybook.Close False
Next
End If
ChDrive SaveDriveDir
ChDir SaveDriveDir
Application.ScreenUpdating = True
End Sub
Function LastRow(sh As Worksheet)
On Error Resume Next
LastRow = sh.Cells.Find(What:="*", _
After:=sh.Range("A1"), _
Lookat:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, _
MatchCase:=False).Row
On Error GoTo 0
End Function