Automatic conversion of text to columns

Vlad2022

New Member
Joined
Nov 5, 2022
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hi

I have a work PC, and whenever I open a .csv file by double-clicking on it it automatically opens in Excel and converts the data into columns. I have recently purchased a home PC, but whenever I open a .csv file on that one by double-clicking (same procedure as I do on the work PC) the file opens in Excel, but the information remains un-formatted (not in columns). I can then run the usual process by going into Data=>Text-to-columns, but since I work with many .csv file doing so every time is a bit of a hassle. Any ideas of how I can make my home PC convert the .csv information into columns automatically upon opening the file, just like my work PC does?

P.S. The .csv files I work with use ";" as separator, not commas.
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Check to be sure the Windows regional settings on your new home PC are the same as for your work PC. For example, on the PC I am using at the moment:

ANSI Code Page setting on this PC is 1252
OEM Console App Code Page setting on this PC is 437

The as-found decimal separator: The period [.] (Ascii 46)
The as-found list separator: The comma [,] (Ascii 44)
The as-found thousands separator: The comma [,] (Ascii 44)

VBA Code:
Sub ListRegionalSettings()
    Dim Msg As String, SepCh As String, SepChDesc As String, SepType As String, SepMsg As String
    Dim ACP As String
    Dim OEMCP As String
    Dim CopySuccess As Boolean

    ACP = CreateObject("WScript.Shell").RegRead("HKLM\SYSTEM\CurrentControlSet\Control\Nls\CodePage\ACP")
    OEMCP = CreateObject("WScript.Shell").RegRead("HKLM\SYSTEM\CurrentControlSet\Control\Nls\CodePage\OEMCP")

    Msg = "ANSI Code Page setting on this PC is " & ACP & vbCr
    Msg = Msg & "OEM Console App Code Page setting on this PC is " & OEMCP & vbCr & vbCr
    SepType = xlDecimalSeparator
    GoSub SepDef
    SepType = xlListSeparator
    GoSub SepDef
    SepType = xlThousandsSeparator
    GoSub SepDef

    Select Case MsgBox(Msg & vbCr & vbCr & "Copy to windows clipboard?", vbQuestion + vbYesNo, "Windows Regional Settings")
    Case vbYes
        On Error Resume Next
        CopySuccess = CreateObject("htmlfile").ParentWindow.ClipboardData.SetData("Text", Msg)
        On Error GoTo 0
        If Not CopySuccess Then
            With CreateObject("New:{1C3B4210-F441-11CE-B9EA-00AA006B1A69}")
                .SetText Msg
                .PutInClipboard
            End With
        End If
    End Select
    Exit Sub

SepDef:
    SepCh = CStr(Application.International(SepType))
    Select Case SepCh
    Case "."
        SepChDesc = "period"
    Case ","
        SepChDesc = "comma"
    Case ";"
        SepChDesc = "semi-colon"
    Case Else
        SepChDesc = "character"
    End Select

    Select Case SepType
    Case xlDecimalSeparator
        SepMsg = "decimal separator:" & Chr(9)
    Case xlListSeparator
        SepMsg = "list separator:" & Chr(9) & Chr(9)
    Case xlThousandsSeparator
        SepMsg = "thousands separator:" & Chr(9)
    Case Else
    End Select
    Msg = Msg & "The as-found " & SepMsg & "The " & SepChDesc & " [" & SepCh & "] (Ascii " & Asc(SepCh) & ")" & vbCr
    Return
End Sub
 
Upvote 0
Solution
Check to be sure the Windows regional settings on your new home PC are the same as for your work PC. For example, on the PC I am using at the moment:

ANSI Code Page setting on this PC is 1252
OEM Console App Code Page setting on this PC is 437

The as-found decimal separator: The period [.] (Ascii 46)
The as-found list separator: The comma [,] (Ascii 44)
The as-found thousands separator: The comma [,] (Ascii 44)

VBA Code:
Sub ListRegionalSettings()
    Dim Msg As String, SepCh As String, SepChDesc As String, SepType As String, SepMsg As String
    Dim ACP As String
    Dim OEMCP As String
    Dim CopySuccess As Boolean

    ACP = CreateObject("WScript.Shell").RegRead("HKLM\SYSTEM\CurrentControlSet\Control\Nls\CodePage\ACP")
    OEMCP = CreateObject("WScript.Shell").RegRead("HKLM\SYSTEM\CurrentControlSet\Control\Nls\CodePage\OEMCP")

    Msg = "ANSI Code Page setting on this PC is " & ACP & vbCr
    Msg = Msg & "OEM Console App Code Page setting on this PC is " & OEMCP & vbCr & vbCr
    SepType = xlDecimalSeparator
    GoSub SepDef
    SepType = xlListSeparator
    GoSub SepDef
    SepType = xlThousandsSeparator
    GoSub SepDef

    Select Case MsgBox(Msg & vbCr & vbCr & "Copy to windows clipboard?", vbQuestion + vbYesNo, "Windows Regional Settings")
    Case vbYes
        On Error Resume Next
        CopySuccess = CreateObject("htmlfile").ParentWindow.ClipboardData.SetData("Text", Msg)
        On Error GoTo 0
        If Not CopySuccess Then
            With CreateObject("New:{1C3B4210-F441-11CE-B9EA-00AA006B1A69}")
                .SetText Msg
                .PutInClipboard
            End With
        End If
    End Select
    Exit Sub

SepDef:
    SepCh = CStr(Application.International(SepType))
    Select Case SepCh
    Case "."
        SepChDesc = "period"
    Case ","
        SepChDesc = "comma"
    Case ";"
        SepChDesc = "semi-colon"
    Case Else
        SepChDesc = "character"
    End Select

    Select Case SepType
    Case xlDecimalSeparator
        SepMsg = "decimal separator:" & Chr(9)
    Case xlListSeparator
        SepMsg = "list separator:" & Chr(9) & Chr(9)
    Case xlThousandsSeparator
        SepMsg = "thousands separator:" & Chr(9)
    Case Else
    End Select
    Msg = Msg & "The as-found " & SepMsg & "The " & SepChDesc & " [" & SepCh & "] (Ascii " & Asc(SepCh) & ")" & vbCr
    Return
End Sub

Thank you very much for replying, I'll try! (I suspected myself that this has to do with regional settings of some sort)
 
Upvote 0

Forum statistics

Threads
1,214,791
Messages
6,121,611
Members
449,038
Latest member
apwr

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top