Tanya VBE

27 views
Skip to first unread message

adi.tahajudin

unread,
Oct 20, 2020, 1:08:50 AM10/20/20
to milis Belajar-Excel
Mau auto Open Workbook di satu folder dengan ketentuan saya mau buka semua file dengan extentions tertentu, contoh *.csv jadi semua yang format nya *.csv ke buka.

bagaimana kah rumusnya, terimakasih master.

Mr. Kid

unread,
Jul 8, 2021, 5:28:24 PM7/8/21
to milis Belajar-Excel
Cara 1 dengan formula :
1. buka workbook kosong, di cells A1 tulis formula :
    ="Kid"
2. ke windows explorer yang berisi files yang akan dibuka bersama-sama (lihat url yang ada di folder tersebut)
3. ketik di kotak search :  *.csv lalu enter
4. tekan CTRL A
5. klik kanan yang terblok -> pilih Open

Cara 2 dengan VBA prosedur sub:
1. buat module general di VBE
2. buat sebuah prosedur untuk mendaftar semua nama file (full file name) yang akan dibuka
3. setiap kali daftarnya bertambah (di dalam blok IF), buka file dengan Workbooks.Open filefullname_yang_baru_masuk_daftar
4. ke object ThisWorkbook -> buat event WorkbookOpen -> isi dengan script untuk menjalankan prosedur yang dibuat di-nomor 2 tadi

 Cara 3 dengan UDF (bikin UDF pakai VBA juga) :
1. buat daftar file yang akan dibuka pada suatu area excel table [bukan sekedar range] (bisa dengan VBA atau lebih bagus dengan power query)
    * jadi formula yang pakai UDF akan secara auto di-copy oleh Excel table ke semua baris yang ada di-excel table tersebut
2. buat module general di VBE
3. buat sebuah blok prosedur function, misal bernama BukaFileExcel
    public function BukaFileExcel(sFile as string) as boolean
         dim app as application
         set app=new excel.application
         app.workbooks.open sfile,2,false
         app.visible
         bukafileexcel=true
    end function
4. ke excel table range tadi, buat kolom baru (kolom baru menjadi kolom terkanan dari excel table) [ubah nama kolom barunya bila perlu]
5. pada record pertama dalam excel table, tulis formula =BukaExcelFile( tunjuk_dengan_mouse_cells_berisi_fullfilename_yang_ada_di_excel_table ) lalu tekan enter
*** syarat dan ketentuan berlaku, resiko ditanggung sendiri...

Regards,
Kid





On Tue, Oct 20, 2020 at 12:08 PM adi.tahajudin <adi.ta...@gmail.com> wrote:
Mau auto Open Workbook di satu folder dengan ketentuan saya mau buka semua file dengan extentions tertentu, contoh *.csv jadi semua yang format nya *.csv ke buka.

bagaimana kah rumusnya, terimakasih master.

--
You received this message because you are subscribed to the Google Groups "milis Belajar-Excel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to milis-belajar-e...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/milis-belajar-excel/14fcd4f8-1b5e-471e-849e-a04e6a064ac4n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages