+ Reply to Thread
Results 1 to 4 of 4

separated by a semicolon

Hybrid View

Kiluk separated by a semicolon 04-17-2013, 06:54 AM
hamjam Re: separated by a semicolon 04-17-2013, 04:05 PM
Kiluk Re: separated by a semicolon 04-18-2013, 02:04 AM
hamjam Re: separated by a semicolon 04-18-2013, 02:38 AM
  1. #1
    Registered User
    Join Date
    06-14-2009
    Location
    Gliwice. Poland
    MS-Off Ver
    Excel 2016
    Posts
    32

    separated by a semicolon

    Welcome.
    Please help change the macro so that the csv file was separated by a semicolon rather than a comma as it is now.

    My macro
    Option Explicit
    Sub PodzielNaPliki()
    Dim Unikaty()
    Dim dane        As Range
    Dim ile         As Long
    Dim i           As Long
    Dim j           As Long
    Dim x           As Long
    
    Application.ScreenUpdating = False
    
    ile = Worksheets("Arkusz1").Cells(Rows.Count, "A").End(xlUp).Row
    Set dane = Worksheets("Arkusz1").Range("A2:A" & ile)
    
    ReDim Unikaty(1 To ile, 1 To 1)
    For i = 1 To ile
        For j = 1 To x
            If dane(i, 1) = Unikaty(j, 1) Then Exit For
        Next j
        If j = x + 1 Then
            x = x + 1
            Unikaty(x, 1) = dane(i, 1)
        End If
    Next i
    
    'tworzenie plików z danymi i ich zapis
    Dim kom             As Range
    Dim a               As Long
    Dim sciezka         As String
    Dim folder          As String
    Dim PlikŹródłowy    As String
    
    PlikŹródłowy = ThisWorkbook.Name
    sciezka = "c:\test"
    folder = Dir(sciezka, vbDirectory)
    If folder = "" Then MkDir sciezka
    
    For i = 1 To x - 1
    a = 2
    Worksheets("Arkusz1").Range("A1:AA1").Copy
    Workbooks.Add
    ActiveSheet.Paste
    ActiveWorkbook.SaveAs Filename:=CStr(sciezka) & "\" & PodnienZnaki(CStr(Unikaty(i, 1))) & ".csv", FileFormat:=xlCSV
    For Each kom In dane
        If kom = Unikaty(i, 1) Then
        Workbooks(PlikŹródłowy).Worksheets("Arkusz1").Range("A" & kom.Row & ":AA" & kom.Row).Copy
        Workbooks(CStr(PodnieńZnaki(CStr(Unikaty(i, 1))) & ".csv")).ActiveSheet.Range("A" & a).PasteSpecial Paste:=xlPasteAll
        Application.CutCopyMode = False
        a = a + 1
        End If
    Next kom
    ActiveWindow.Close SaveChanges:=True
    Next i
    
    Application.ScreenUpdating = True
    End Sub
    Function PodnienZnaki(nazwisko As String) As String
    Dim i      As Integer
    Dim nowy   As String
    
    nowy = ""
    For i = 1 To Len(nazwisko)
        If Mid(nazwisko, i, 1) Like "[/\:*?<>|]" Or _
           Mid(nazwisko, i, 1) = Chr(34) Then
            Mid(nazwisko, i, 1) = "_"
        End If
    nowy = nowy & Mid(nazwisko, i, 1)
    Next
    PodnieńZnaki = nowy
    End Function
    kiluk
    Last edited by Kiluk; 04-17-2013 at 07:03 AM.

  2. #2
    Forum Contributor
    Join Date
    01-07-2013
    Location
    south africa
    MS-Off Ver
    Excel 2003-13
    Posts
    210

    Re: separated by a semicolon

    Hello
    As there is no Excel file export to separate values by semicolon, I suggest you use a text editor - for example notepad.
    Open the file, go to edit and do a replace "," with ";"
    Should take you no longer than 1 minute to resolve.

    Regards
    Most helpful to mark solved items as such (see help for directions). Star ratings are always welcome.

  3. #3
    Registered User
    Join Date
    06-14-2009
    Location
    Gliwice. Poland
    MS-Off Ver
    Excel 2016
    Posts
    32

    Re: separated by a semicolon

    thank you.

    Unfortunately, your solution will not work because I need to have 100,000 rows in the xls file to csv file 30.
    Kiluk

  4. #4
    Forum Contributor
    Join Date
    01-07-2013
    Location
    south africa
    MS-Off Ver
    Excel 2003-13
    Posts
    210

    Re: separated by a semicolon

    Hello Kiluk
    I would not reject that solution because of size, I created a sample spreadsheet consisting of 5 columns and 200,000 rows, i.e. 1 million records and it worked just fine with trusty old notepad.

    Regards

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1