ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[µo°Ý] ¸óÀɮרú±o¨ä¤¤¬Ysheet¤ºªº¬YÄæ¦ì­È¡AÀ³¸Ó¦p¦ó¨Ï¥ÎVBA¼¶¼g?

°²³]§A­nªº¸ê®Æ¦s©ó¬¡­¶Ã¯2(¨Ã¥¼¶}±Ò)¤¤¤u§@ªí1ªºA1
¦Ó§A­n§â³o¸ê®Æ©ñ¨ì¥Ø«e§@¥Î¤¤¤u§@ªíªºA1
Code ¦p¤U:
Cells(1, 1).Formula = "='[¬¡­¶Ã¯2.xlsx]¤u§@ªí1'!$A$1"         ' for Excel 2010
Alex

TOP

¥»©«³Ì«á¥Ñ alexliou ©ó 2012-3-28 07:50 ½s¿è

¤]¥i¥H§Q¥Î©I¥sexcel ´£¨Ñªº XLM macro¨Ó¹F¦¨.
©³¤Uªº GetValue Function¦³¥|­Ó¤Þ¼Æ :
¡Epath: ¸ê®Æ©Ò¦bÀɮתº¸ô®| (e.g., "d:\Data\ or d:\Data")
¡Efile: ¬¡­¶Ã¯¦WºÙ (e.g., "Input.xls" or "Input.xlsx)
¡Esheet: ¤u§@ªí¦WºÙ (e.g., "Sheet1")
¡Eref: §A©Ò­nªº­È©Ò¦bÀx¦s®æªº¦ì§}°Ñ·Ó (e.g., "C5")

Private Function GetValue(path, file, sheet, ref)
'   ±q¤@­ÓÃö³¬ªº¬¡­¶Ã¯¤¤¨ú¸ê®Æ
    Dim arg As String
'   ½T©wÀɮצs¦b
    If Right(path, 1) <> "\" Then path = path & "\"
    If Dir(path & file) = "" Then
        GetValue = "File Not Found"
        Exit Function
    End If
'   ³]©w°õ¦æXLM Macroªº°Ñ¼Æ
    arg = "'" & path & "[" & file & "]" & sheet & "'!" & Range(ref).Range("A1").Address(, , xlR1C1)
'   °õ¦æMicrosoft Excel 4.0 ¥¨¶°
    GetValue = ExecuteExcel4Macro(arg)
End Function
Alex

TOP

¥»©«³Ì«á¥Ñ alexliou ©ó 2012-3-29 07:32 ½s¿è

¦^´_ 6# VANESSA
ªþ¥ó¤¤¦³¨â­ÓÀÉ®×
¬¡­¶Ã¯2¬OÃö³¬¤¤(¶}±Ò¤¤ªº¤]workable)ªºÀÉ®×, §A©Ò­nªº¸ê®Æ°²³]¦b¨ä¤¤¤u§@ªí1ªº"D3"Àx¦s®æ
¬¡­¶Ã¯2½Ð§â¥¦©ñ¨ì C:\Users\user\Documents ¸ê®Æ§¨
³o­ÓÀɮשñ¨ì­þ¸Ì±N·|¼vÅT¨ìGetValue¨ç¼Æªº²Ä¤@­Ó¤Þ¼Æ
¬¡­¶Ã¯1ªº¤u§@ªí1¬O¥Ø«e§@¥Î¤¤ªº¤u§@ªí
©R¥O«ö¶sªº¤u§@«Ü³æ¯Â
´N¬O¥h°õ¦æ  Cells(1, 1).Value = GetValue("C:\Users\user\Documents", "¬¡­¶Ã¯2.xlsx", "¤u§@ªí1", "D3")
¬¡­¶Ã¯1.zip (25.87 KB)
Alex

TOP

        ÀR«ä¦Û¦b : §Ú­Ì³Ì¤jªº¼Ä¤H¤£¬O§O¤H¡D¥i¯à¬O¦Û¤v¡C
ªð¦^¦Cªí ¤W¤@¥DÃD