Sub list2txt() Dim zadnjaKolona As Long Dim zadnjiRed As Long zadnjaKolona = LastCol(ActiveSheet) zadnjiRed = LastRow(ActiveSheet) Dim folderPath As String folderPath = Application.ActiveWorkbook.Path Dim imeFile As String Dim strDatum As String strDatum = Format(Date, "dd_mm_yyyy") imeFile = folderPath & "\" & "zaposlenici_" & strDatum & ".txt" 'obrisi datoteku ako postoji sa tim imenom 'ne radi na stiku 'If FileExists(imeFile) Then ' SetAttr imeFile, vbNormal ' ako postoji readonly atribut (samo citanje) makni ga ' Kill imeFile ' obrisi file 'End If Dim ff As Integer ff = FreeFile() Dim celija1 As String 'Id kolona=1 Dim celija2 As String 'ime i prezime kolona=2 Dim celija3 As String 'prezime kolona=3 Dim celija4 As String 'telefon kolona=4 Dim celija5 As String 'adresa kolona=5 Dim celija6 As String 'dat.rod. kolona=6 Dim celija7 As String 'koef.obr kolona=7 Dim celija8 As String 'kat.r.m. kolona=11 Dim celija9 As String 'o.d. kolona=9 Dim celija10 As String 'o.d.dod kolona=10 Dim celija11 As String 'tje.st kolona=12 Dim strListBox As String Open imeFile For Output As #ff For red = 2 To zadnjiRed celija1 = Cells(red, 1).Value 'id celija2 = Cells(red, 2).Value & " " & Cells(red, 3).Value 'ime celija3 = Cells(red, 4).Value 'telefon celija4 = Cells(red, 5).Value 'adresa celija5 = Format(Cells(red, 6).Value, "yyyy-mm-dd") 'datum rodenja celija6 = Cells(red, 7).Value 'koeficijent obrazovanja celija7 = Cells(red, 8).Value 'kategorija radnog mjesta celija8 = Cells(red, 9).Value 'osobni dohodak celija9 = Cells(red, 10).Value 'osobni dohodak dodatak celija10 = Cells(red, 11).Value 'tjedno sati Write #ff, celija1, celija2, celija3, celija4, celija5, celija6, celija7, celija8, celija9, celija10 Next red Close #ff End Sub 'DALI DATOTEKA POSTOJI Public Function FileExists(ByVal FileToTest As String) As Boolean FileExists = (Dir(FileToTest) <> "") End Function 'PRONALAZI ZADNJI REED Public 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 'PRONALAZI ZADNJU KOLONU Public Function LastCol(sh As Worksheet) On Error Resume Next LastCol = sh.Cells.Find(What:="*", _ After:=sh.Range("A1"), _ LookAt:=xlPart, _ LookIn:=xlFormulas, _ SearchOrder:=xlByColumns, _ SearchDirection:=xlPrevious, _ MatchCase:=False).Column On Error GoTo 0 End Function