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

[µo°Ý] Àx¦s®æ¯Á¤Þ­È

¦^´_ 5# PJChen

¥\¤O¨S«Ü¦n,½Ð¸Õ¸Õ
¸ê®Æ§¨³]©w¬°A,¦p­nÅܰʽЦۦæ­×§ï(§tÀx¦s¸ô®|)

Sub ´ú¸Õ()
Dim Wb As Workbook, Sh As Worksheet, x As Range, Source1 As String
    Source1 = Workbooks("Macro.xlsm").Worksheets("VBA").Range("B1").Value '­n¶}±ÒªºÀɮצWºÙ
    Workbooks.Open "c:\A\" & Source1 & ".xlsx" '¶}±Ò­n¼g¤JªºÀÉ®×   
    Workbooks("Macro.xlsm").Activate   
    Set Wb = Workbooks(Workbooks("Macro.xlsm").Worksheets("VBA").Range("B1").Value) 'Àx¦s®æªº­È¬°ÀɮצWºÙ
    Set Sh = Wb.Worksheets(Worksheets("VBA").Range("B2").Text)  'Àx¦s®æªº­È¬°¤u§@ªí¦WºÙ,¦]¬°¤u§@ªí¦WºÙ¬O¼Æ¦r,·|³Q·í¦¨"¼Æ²ÄN­Ó¤u§@ªí",ÁÙµLªk¸Ñ¨M,¥H¥[1¥ý¼È¥Î      
    Sh.Activate
    With Sh
    Set x = Sh.Range(Workbooks("Macro.xlsm").Worksheets("VBA").Range("B5").Text) '«ü©w¼g¤JªºÀx¦s®æ¬°©ñ¦b¨º­ÓÄæ¦ì
     x = Workbooks("Macro.xlsm").Worksheets("VBA").Range("B4").Text '¼g¤Hªº­È©ñ¦b¨º­ÓÄæ¦ì
    End With
    Workbooks(Dir("C:\A\" & Source1 & ".xlsx")).Close True 'Ãö³¬¨ÃÀx¦s¼g¤JªºÀÉ®×
End Sub

TOP

¦^´_ 4# jcchiang

ÁÂÁ§A,§ï¬°text¯uªº´N¥i¥H¤F¡I
³Ñ¤U²Ä4­Ó°ÝÃDÁÙ¨S¸Ñ¨M
¥i¥Hªº¸Ü,¤]½Ð«ü¾É¤@¤U,ÁÂÁ                ´ú¸Õ.rar (40.88 KB)

B6¬°«ü©w¸ê®Æ§¨¦WºÙA
¸Ì­±¦³N­ÓÀÉ®×
¨C­ÓÀɮתº¤u§@ªí³£¥H¼Æ¦r©R¦W,¨Ò:1¡K2¡K3¡K
µ{¦¡¼g¦bMacro.xlsm¤¤,
§Ú·Q«ü©wªº¤u§@ªí¦WºÙ©ñ¦bB2Äæ¦ì
¦Ó­n¼g¤Hªº­È©ñ¦bB4Äæ¦ì
«ü©w¼g¤JªºÀx¦s®æ¬°©ñ¦bB2Äæ¦ì
§Ú§â©Ò­n°µªº¨Æ³£©ñ¦bMacro.xlsmªº¤u§@ªíVBA¤¤,
¥u­n±q³o¸Ì­×§ï­È,´N¥i¥HÀ°§Ú¼g¤J¸ê®Æ
½Ð°Ý­n¦p¦ó¼g³o¬qVBA?¥i¥HÅý¥¦¨Ì§Ç¼g¤J«ü©wªº¸ê®Æ§¨A?

TOP

¦^´_ 1# PJChen

Set Sh = Wb.Worksheets(Worksheets("VBA").Range("B2").Value) 'Àx¦s®æªº­È¬°¤u§@ªí¦WºÙ

§ï¬°
Set Sh = Wb.Worksheets(Worksheets("VBA").Range("B2").Text) 'Àx¦s®æªº­È¬°¤u§@ªí¦WºÙ

TOP

¦^´_ 1# PJChen

§Ú¤]¤£¬O«Ü¤F¸ÑÀɮתºÃöÁp©Ê
©Ò¥H±Nsh§ï¬°¦r¦ê,´N¥i¥H«ü¦V©Ò³]©w¦WºÙªºsheet

Sub ´ú¸Õ()
Dim Wb As Workbook, sh As String, x As Range
'   Set Wb = Workbooks(Workbooks("Macro.xlsm").Worksheets("VBA").Range("B1").Value) 'Àx¦s®æªº­È¬°ÀɮצWºÙ
    sh = Worksheets("VBA").Range("B2") 'Àx¦s®æªº­È¬°¤u§@ªí¦WºÙ
    Worksheets(sh).Activate
    With Worksheets(sh)
    Set x = .Range("B4")
    x = Worksheets("VBA").Range("B4").Value '«ü©w1.sheet¤é´Á
    End With
End Sub

TOP

¦^´_ 1# PJChen


    ½Ð°Ý©pªº³o¤äµ{§Ç¥D­n¥Øªº¬°¦ó¡H
    ¬O­n±N«ü©w¤u§@ªí¨Ì¾Ú¤é´Á¨Ó°µ©R¦W¶Ü¡H

   ¬Ý¤£À´©pªºB2¡BB3¤ÎB4³]©w¡A¬G¦¹¸ß°Ý¡C

TOP

        ÀR«ä¦Û¦b : ¥@¤W¦³¨â¥ó¨Æ¤£¯àµ¥¡G¤@¡B§µ¶¶ ¤G¡B¦æµ½¡C
ªð¦^¦Cªí ¤W¤@¥DÃD