Hai Fano,

Prosedur berikut membutuhkan data di kolom F pada sheet bernama 'data'
minimal 2 nilai.
Public Sub CreateTxtFile()
    Dim sPath As String, sFile As String, sTxt(1 To 6) As String
    Dim lRow As Long, lRows As Long, sht As Worksheet
    Dim dblTime As Double

    dblTime = Timer
    Set sht = ThisWorkbook.Worksheets("data")
    With sht
        lRows = .Range("f1").CurrentRegion.Resize(, 1).Count - 1
        If lRows < 1 Then
            Exit Sub
        End If
        sPath = ThisWorkbook.Path & "\level_"   'simpan folder hasil
beserta prefix nama file
        'Kill sPath & "*.txt"                   'hapus hasil yang lama
(aktifkan bila perlu)

        'nilai data yang konstan
        sTxt(1) = String$(42, "#")
        'creation date dibuat sama per klik create
        sTxt(2) = "# Creation Date : " & Format$(Now, "DDD MMM HH:nn:ss
YYYY")
        sTxt(6) = sTxt(1)

        'loop create file
        For lRow = 1 To lRows
            sFile = sPath & lRow & ".txt"    'nama file (fullname)

            sTxt(3) = "# Level" & String$(10, " ") & ": " & lRow
            '6 adalah kolom F
            sTxt(4) = "# Above" & String$(10, " ") & ": " & .Cells(lRow,
6).Value
            sTxt(5) = "# Below" & String$(10, " ") & ": " & .Cells(lRow +
1, 6).Value

            'tulis jadi file
            Open sFile For Output As #1
            Print #1, Join(sTxt, vbCrLf)
            Close #1
        Next lRow
    End With
    MsgBox "Done." & vbCrLf & _
            lRows & " files created in " & Timer - dblTime & " seconds." _
            , vbInformation, "Create txt files"
End Sub


Wassalam,
Kid.




2014/1/19 Fano The Miner <[email protected]>

>
>
> *Dear All,*
>
> *Mohon bantuannya teman-teman* *Be-Exceler.*
>
>
>
> 1.       Saya punya prosedur vba untuk membuat file txt. Sheet "
> *sheet_txt*" berisi formula yang  terintegrasi dengan sheet "*data*".
> Jika tombol *Create txt file *saya tekan maka akan ter-create file txt
> sebanyak data count.
>
> 2.       Permasalannya, saya mempunyai data hampir ribuan, artinya, saya
> harus  menekan tombol *Create txt file *sebanyak hampir ribuan di tiap
> pekerjaan saya.  Yang ingin saya inginkan dan belum saya ketahui adalah
> bagaimana me-*LOOP */ *mengulang *prosedur tersebut hanya dengan sekali
> tekan tombol tersebut maka akan di-create data sebanyak  itu.
>
>
>
> Untuk lebih jelasnya, illustrasi ada dalam file lampiran.
>
>
>
>
>
> Mohon Bantuannya.
>
> *Terima Kasih, *
>
> *Salam.*
>
> IRFANO *"the miner"*
>
>  
>

Kirim email ke