麻辣家族討論版版's Archiver

marionlongly 發表於 2018-5-16 11:15

Vlookup參照檔可隨日期變更嗎?

各位先進,欲使用vlookup查找資料,
但參照檔案檔名會隨日期變更,如圖紅框處,
是否有辦法讓它自動隨檔案日期變更?
[attach]28721[/attach][attach]28721[/attach]

nolookyou 發表於 2018-5-16 11:54

[i=s] 本帖最後由 nolookyou 於 2018-5-16 11:56 編輯 [/i]

[b]回復 [url=http://forum.twbts.com/redirect.php?goto=findpost&pid=103479&ptid=20792]1#[/url] [i]marionlongly[/i] [/b]


    可以,改成用VBA寫,在打開工作表時的Workbook_Open()區段,用VBA寫入公式,日期部分用變數取當天日期即可~

marionlongly 發表於 2018-5-16 13:05

[b]回復 [url=http://forum.twbts.com/redirect.php?goto=findpost&pid=103480&ptid=20792]2#[/url] [i]nolookyou[/i] [/b]

nolookyou 大大,
請問vba指令該如何撰寫呢?
因為對vba的領域完全不了解,
感謝你~

nolookyou 發表於 2018-5-16 14:38

[b]回復 [url=http://forum.twbts.com/redirect.php?goto=findpost&pid=103482&ptid=20792]3#[/url] [i]marionlongly[/i] [/b]


    先看一下影片
    看這是不是你要的結果
    [attach]28722[/attach]

nolookyou 發表於 2018-5-16 14:54

[b]回復 [url=http://forum.twbts.com/redirect.php?goto=findpost&pid=103482&ptid=20792]3#[/url] [i]marionlongly[/i] [/b]


    喔!!看到版大對VBA不了解,那就不用VBA,用純公式也可以解,
    在A1儲存格插入以下公式即可達到我上面影片內用VBA的效果,
   
    提醒一下就是,跨檔案做VLOOKUP時,2個檔案都要開著喔!!
    請版大測試一下:

    =IF(H4=0,"",VLOOKUP(H4, INDIRECT("'C:\ABC\DEF\GHI\JKL\[MNO"&TEXT(TODAY(),"mmdd")&".xlsx]測試'!$M:$AR"), 32, 0))

kyouitsu 發表於 2021-1-21 08:08

[b]回復 [url=http://forum.twbts.com/redirect.php?goto=findpost&pid=103485&ptid=20792]5#[/url] [i]nolookyou[/i] [/b]


    感謝分享

頁: [1]

麻辣家族討論版版為 麻辣學園 網站成員  由 昱得資訊工作室 © Since 1993 所提供