Forum Sementara Putera.com

Would you like to react to this message? Create an account in a few clicks or log in to continue.
Forum Sementara Putera.com

Bersama kita perkemaskan forum ini sementara forum asal dalam pemulihan.

Forum putera dah kembali. Masalah sudah berjaya diselesaikan. Sila lawati http://forum.putera.com/tanya


4 posters

    VBA [VB EXCEL]

    putri
    putri
    Ahli Baharu
    Ahli Baharu


    Gender : Female Number of posts : 87
    Location : Jay Bee
    Job/hobbies : suka kumpul kasut byk2
    Registration date : 17/07/2009

    VBA [VB EXCEL] Empty VBA [VB EXCEL]

    Post by putri Wed Aug 05, 2009 12:18 pm

    SALAM SUMER...
    NK TYE LA MCM MANE NK EXPORT FILE .txt KE .xls BILA TEKAN CMD BUTTON????
    Spe ley bntu??
    johnburn
    johnburn
    Moderators
    Moderators


    Gender : Male Number of posts : 755
    Location : Terengganu
    Registration date : 07/03/2009

    VBA [VB EXCEL] Empty Re: VBA [VB EXCEL]

    Post by johnburn Wed Aug 05, 2009 12:32 pm

    format dlm text file tu cmne?
    putri
    putri
    Ahli Baharu
    Ahli Baharu


    Gender : Female Number of posts : 87
    Location : Jay Bee
    Job/hobbies : suka kumpul kasut byk2
    Registration date : 17/07/2009

    VBA [VB EXCEL] Empty Re: VBA [VB EXCEL]

    Post by putri Wed Aug 05, 2009 12:35 pm

    johnburn wrote:format dlm text file tu cmne?

    format .txt la...
    putri
    putri
    Ahli Baharu
    Ahli Baharu


    Gender : Female Number of posts : 87
    Location : Jay Bee
    Job/hobbies : suka kumpul kasut byk2
    Registration date : 17/07/2009

    VBA [VB EXCEL] Empty Re: VBA [VB EXCEL]

    Post by putri Wed Aug 05, 2009 5:11 pm

    putri wrote:SALAM SUMER...
    NK TYE LA MCM MANE NK EXPORT FILE .txt KE .xls BILA TEKAN CMD BUTTON????
    Spe ley bntu??


    xde sape ke nk tolong putri??
    cmne ni??
    confused confused confused
    chaer89
    chaer89
    Ahli Baharu
    Ahli Baharu


    Gender : Male Number of posts : 194
    Age : 34
    Registration date : 15/03/2009

    VBA [VB EXCEL] Empty Re: VBA [VB EXCEL]

    Post by chaer89 Thu Aug 06, 2009 10:55 am

    kna wat link la.
    putri
    putri
    Ahli Baharu
    Ahli Baharu


    Gender : Female Number of posts : 87
    Location : Jay Bee
    Job/hobbies : suka kumpul kasut byk2
    Registration date : 17/07/2009

    VBA [VB EXCEL] Empty Re: VBA [VB EXCEL]

    Post by putri Thu Aug 06, 2009 11:27 am

    chaer89 wrote:kna wat link la.

    cmne ekh nk wt link??
    chaer89
    chaer89
    Ahli Baharu
    Ahli Baharu


    Gender : Male Number of posts : 194
    Age : 34
    Registration date : 15/03/2009

    VBA [VB EXCEL] Empty Re: VBA [VB EXCEL]

    Post by chaer89 Thu Aug 06, 2009 12:10 pm

    klo xslap la..
    pkai ADODC ada tool bar 2..
    lpa dah
    avatar
    DevGuy
    Ahli Baharu
    Ahli Baharu


    Number of posts : 90
    Registration date : 16/03/2009

    VBA [VB EXCEL] Empty Re: VBA [VB EXCEL]

    Post by DevGuy Thu Aug 06, 2009 12:26 pm

    ada cara senang.content utk txt file tu apa.cuba kasi sample sikit.senang orang nak tolong
    kalau guna .net kita leh export terus text file tu ker excel

    ok
    putri
    putri
    Ahli Baharu
    Ahli Baharu


    Gender : Female Number of posts : 87
    Location : Jay Bee
    Job/hobbies : suka kumpul kasut byk2
    Registration date : 17/07/2009

    VBA [VB EXCEL] Empty Re: VBA [VB EXCEL]

    Post by putri Thu Aug 06, 2009 12:28 pm

    chaer89 wrote:klo xslap la..
    pkai ADODC ada tool bar 2..
    lpa dah

    dalam vb excel ade ADODC Kew??
    xsure la..
    avatar
    Guest
    Guest


    VBA [VB EXCEL] Empty Re: VBA [VB EXCEL]

    Post by Guest Thu Aug 06, 2009 12:30 pm

    What they mean is, the txt content, is it in CSV or other format.
    putri
    putri
    Ahli Baharu
    Ahli Baharu


    Gender : Female Number of posts : 87
    Location : Jay Bee
    Job/hobbies : suka kumpul kasut byk2
    Registration date : 17/07/2009

    VBA [VB EXCEL] Empty Re: VBA [VB EXCEL]

    Post by putri Thu Aug 06, 2009 12:47 pm

    iluvkarim.selamat wrote:What they mean is, the txt content, is it in CSV or other format.


    the txt content is it in DAT format...
    putri
    putri
    Ahli Baharu
    Ahli Baharu


    Gender : Female Number of posts : 87
    Location : Jay Bee
    Job/hobbies : suka kumpul kasut byk2
    Registration date : 17/07/2009

    VBA [VB EXCEL] Empty Re: VBA [VB EXCEL]

    Post by putri Thu Aug 06, 2009 12:49 pm

    DevGuy wrote:ada cara senang.content utk txt file tu apa.cuba kasi sample sikit.senang orang nak tolong
    kalau guna .net kita leh export terus text file tu ker excel

    ok



    txt file ni format DAT...
    ??
    putri
    putri
    Ahli Baharu
    Ahli Baharu


    Gender : Female Number of posts : 87
    Location : Jay Bee
    Job/hobbies : suka kumpul kasut byk2
    Registration date : 17/07/2009

    VBA [VB EXCEL] Empty Re: VBA [VB EXCEL]

    Post by putri Thu Aug 06, 2009 5:18 pm

    erm.. cmne ni?? confused
    avatar
    Guest
    Guest


    VBA [VB EXCEL] Empty Re: VBA [VB EXCEL]

    Post by Guest Thu Aug 06, 2009 5:20 pm

    Can you attach a sample of the .dat file.
    That might clear things up.
    putri
    putri
    Ahli Baharu
    Ahli Baharu


    Gender : Female Number of posts : 87
    Location : Jay Bee
    Job/hobbies : suka kumpul kasut byk2
    Registration date : 17/07/2009

    VBA [VB EXCEL] Empty Re: VBA [VB EXCEL]

    Post by putri Thu Aug 06, 2009 5:56 pm

    iluvkarim.selamat wrote:Can you attach a sample of the .dat file.
    That might clear things up.


    sory..
    i think cant' because that is private file..
    have another way?
    avatar
    DevGuy
    Ahli Baharu
    Ahli Baharu


    Number of posts : 90
    Registration date : 16/03/2009

    VBA [VB EXCEL] Empty Re: VBA [VB EXCEL]

    Post by DevGuy Fri Aug 07, 2009 12:42 am

    kasi aaa sample sikit biar orang senang nak tolong. hadus. kalau tak derr tak dapat aa den nak tolong yekkk
    avatar
    Guest
    Guest


    VBA [VB EXCEL] Empty Re: VBA [VB EXCEL]

    Post by Guest Fri Aug 07, 2009 10:16 am

    adeh. sample la, not the actual file.
    johnburn
    johnburn
    Moderators
    Moderators


    Gender : Male Number of posts : 755
    Location : Terengganu
    Registration date : 07/03/2009

    VBA [VB EXCEL] Empty Re: VBA [VB EXCEL]

    Post by johnburn Fri Aug 07, 2009 12:20 pm

    johnburn wrote:format dlm text file tu cmne?
    DevGuy wrote:ada cara senang.content utk txt file tu apa.cuba kasi sample sikit.senang orang nak tolong
    kalau guna .net kita leh export terus text file tu ker excel

    ok
    iluvkarim.selamat wrote:Can you attach a sample of the .dat file.
    That might clear things up.
    DevGuy wrote:kasi aaa sample sikit biar orang senang nak tolong. hadus. kalau tak derr tak dapat aa den nak tolong yekkk
    iluvkarim.selamat wrote:adeh. sample la, not the actual file.
    Hehe, tujuan ktorng mntk ni sbb nk tgk frmt data dlm text file tu untk memudahkn pengmbilan data.

    Code:

    Public Sub ImportText(namaFile As String, pemisah As String)

    Dim baris As Long
    Dim lajur As Integer
    Dim TempVal As Variant
    Dim WholeLine As String
    Dim Pos As Integer
    Dim NextPos As Integer
    Dim Savelajur As Integer

    Application.ScreenUpdating = False
    'On Error GoTo EndMacro:

    Savelajur = ActiveCell.Column
    baris = ActiveCell.Row

    Open namaFile For Input Access Read As #1

    While Not EOF(1)
        Line Input #1, WholeLine
        If Right(WholeLine, 1) <> pemisah Then
            WholeLine = WholeLine & pemisah
        End If
        lajur = Savelajur
        Pos = 1
        NextPos = InStr(Pos, WholeLine, pemisah)
        While NextPos >= 1
            TempVal = Mid(WholeLine, Pos, NextPos - Pos)
            Cells(baris, lajur).Value = TempVal
            Pos = NextPos + 1
            lajur = lajur + 1
            NextPos = InStr(Pos, WholeLine, pemisah)
        Wend
        baris = baris + 1
    Wend

    EndMacro:
    On Error GoTo 0
    Application.ScreenUpdating = True
    Close #1
    End Sub
    Dalam contoh kod diatas, namaFile tu merupakan nama text file yg nk di import ke dlm excel. ko bleh spesifikkn data dlm text file tu dipisahkan oleh apa, sebagai cnth, kl dlm text file tu data die cmni:
    data1, data2, data3

    So ko bleh nmpk data dlm file text tu dipisahkan oleh koma. untuk memudahkn ko pilih file dan spesifikkan pemisah untuk data, bleh pkai ni:
    Code:

    Sub ImportFileSetPemisah()
        Dim FileName As Variant
        Dim pemisah As String
        FileName = Application.GetOpenFilename(FileFilter:="Text File (*.txt),*.txt")
        If FileName = False Then

            Exit Sub
        End If
        pemisah = Application.InputBox("Masukkan aksara pemisah.", Type:=2)
        If pemisah = vbNullString Then

            Exit Sub
        End If
        Debug.Print "Nama Fail: " & FileName, "Pemisah: " & pemisah
        ImportText namaFile:=CStr(FileName), pemisah:=CStr(pemisah)
    End Sub
    putri
    putri
    Ahli Baharu
    Ahli Baharu


    Gender : Female Number of posts : 87
    Location : Jay Bee
    Job/hobbies : suka kumpul kasut byk2
    Registration date : 17/07/2009

    VBA [VB EXCEL] Empty Re: VBA [VB EXCEL]

    Post by putri Mon Aug 10, 2009 9:55 am

    DevGuy wrote:kasi aaa sample sikit biar orang senang nak tolong. hadus. kalau tak derr tak dapat aa den nak tolong yekkk

    Guest wrote:adeh. sample la, not the actual file.


    huhuhu...
    sory guys...
    nk sample cmne 2???
    xphm deh...
    hehehe....
    Razz
    putri
    putri
    Ahli Baharu
    Ahli Baharu


    Gender : Female Number of posts : 87
    Location : Jay Bee
    Job/hobbies : suka kumpul kasut byk2
    Registration date : 17/07/2009

    VBA [VB EXCEL] Empty Re: VBA [VB EXCEL]

    Post by putri Mon Aug 10, 2009 9:58 am

    johnburn wrote:
    johnburn wrote:format dlm text file tu cmne?
    DevGuy wrote:ada cara senang.content utk txt file tu apa.cuba kasi sample sikit.senang orang nak tolong
    kalau guna .net kita leh export terus text file tu ker excel

    ok
    iluvkarim.selamat wrote:Can you attach a sample of the .dat file.
    That might clear things up.
    DevGuy wrote:kasi aaa sample sikit biar orang senang nak tolong. hadus. kalau tak derr tak dapat aa den nak tolong yekkk
    iluvkarim.selamat wrote:adeh. sample la, not the actual file.
    Hehe, tujuan ktorng mntk ni sbb nk tgk frmt data dlm text file tu untk memudahkn pengmbilan data.

    Code:

    Public Sub ImportText(namaFile As String, pemisah As String)

    Dim baris As Long
    Dim lajur As Integer
    Dim TempVal As Variant
    Dim WholeLine As String
    Dim Pos As Integer
    Dim NextPos As Integer
    Dim Savelajur As Integer

    Application.ScreenUpdating = False
    'On Error GoTo EndMacro:

    Savelajur = ActiveCell.Column
    baris = ActiveCell.Row

    Open namaFile For Input Access Read As #1

    While Not EOF(1)
        Line Input #1, WholeLine
        If Right(WholeLine, 1) <> pemisah Then
            WholeLine = WholeLine & pemisah
        End If
        lajur = Savelajur
        Pos = 1
        NextPos = InStr(Pos, WholeLine, pemisah)
        While NextPos >= 1
            TempVal = Mid(WholeLine, Pos, NextPos - Pos)
            Cells(baris, lajur).Value = TempVal
            Pos = NextPos + 1
            lajur = lajur + 1
            NextPos = InStr(Pos, WholeLine, pemisah)
        Wend
        baris = baris + 1
    Wend

    EndMacro:
    On Error GoTo 0
    Application.ScreenUpdating = True
    Close #1
    End Sub
    Dalam contoh kod diatas, namaFile tu merupakan nama text file yg nk di import ke dlm excel. ko bleh spesifikkn data dlm text file tu dipisahkan oleh apa, sebagai cnth, kl dlm text file tu data die cmni:
    data1, data2, data3

    So ko bleh nmpk data dlm file text tu dipisahkan oleh koma. untuk memudahkn ko pilih file dan spesifikkan pemisah untuk data, bleh pkai ni:
    Code:

    Sub ImportFileSetPemisah()
        Dim FileName As Variant
        Dim pemisah As String
        FileName = Application.GetOpenFilename(FileFilter:="Text File (*.txt),*.txt")
        If FileName = False Then

            Exit Sub
        End If
        pemisah = Application.InputBox("Masukkan aksara pemisah.", Type:=2)
        If pemisah = vbNullString Then

            Exit Sub
        End If
        Debug.Print "Nama Fail: " & FileName, "Pemisah: " & pemisah
        ImportText namaFile:=CStr(FileName), pemisah:=CStr(pemisah)
    End Sub




    thx arr..
    da try da cdg ni...
    tp xtw jd x??
    huhuhu
    sory la xbg sample...
    xtw nk bg sample cmne..
    pape pon thx..
    johnburn
    johnburn
    Moderators
    Moderators


    Gender : Male Number of posts : 755
    Location : Terengganu
    Registration date : 07/03/2009

    VBA [VB EXCEL] Empty Re: VBA [VB EXCEL]

    Post by johnburn Mon Aug 10, 2009 10:34 am

    Ok, contoh data yang diminta tu adalah untuk melihat samada data dalam file tu merupakan delimited data (setiap nilai dipisahkan oleh satu aksara). Contohnya katakan saya ada satu text file yang bernama data.txt, dan kandungan dalamnya adalh seperti berikut:
    Code:

    LastName,FirstName,MiddleInitial
    Myer,Ken,W
    Poe, Deborah,L
    Dari sini sy dpt tau data dlm text file tu merupakkan comma delimited data, dan ini akn memudahkan sy untuk mengimport data tersebut kedlm excel.
    avatar
    DevGuy
    Ahli Baharu
    Ahli Baharu


    Number of posts : 90
    Registration date : 16/03/2009

    VBA [VB EXCEL] Empty Re: VBA [VB EXCEL]

    Post by DevGuy Mon Aug 10, 2009 6:03 pm

    ala senang actual file tu ko edit sikit.taruk aa ali ker abu ker apa22 ker nama kereta ker sukati aa nak taruk apa. ko amik la dlam 5 data kerr lepas tu copy and paste kat sini tu jerrr
    putri
    putri
    Ahli Baharu
    Ahli Baharu


    Gender : Female Number of posts : 87
    Location : Jay Bee
    Job/hobbies : suka kumpul kasut byk2
    Registration date : 17/07/2009

    VBA [VB EXCEL] Empty Re: VBA [VB EXCEL]

    Post by putri Tue Aug 18, 2009 4:22 pm

    thx sumer....
    t aq try....
    Very Happy

    Sponsored content


    VBA [VB EXCEL] Empty Re: VBA [VB EXCEL]

    Post by Sponsored content


      Current date/time is Thu May 02, 2024 10:44 pm