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
Bookmarks