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

[µo°Ý] excel¥Îvba¨Ì§Ç¶}±ÒÀÉ®×

[µo°Ý] excel¥Îvba¨Ì§Ç¶}±ÒÀÉ®×

¤£¦n·N«ä·Q½Ð°Ý¦p¦ó¦bexcel¥Îvba¨Ì§Ç¶}±ÒÀÉ®×

­ì·Qªk¬O¥Î°j°éªº¤è¦¡¥h¨Ì§Ç¶}±ÒÀx¦s®æ¤¤ªº¸ô®|
¸ô®|¼g¦b¤u§@ªí¤¤sheet1ªºA1 ©MA2 ( C:\vbatest1.xls ©M C:\vbatest2.xls )
vba¦p¤U, ¦ýµLªk¶¶§Qrun, ¤£ª¾¥i§_À°¦£¸Ñµª / ­×§ï¿ù»~ªº¦a¤è
·P¿E!!!

Dim filename As String
Dim i As Integer

For i = 1 To 2

i = i + 0

Worksheets("Sheet1").Cells(i, 1) = filename

Workbooks.Open "filename"

Next

¦^´_ 1# xoofer


    ¸Õ¸Õ¬Ý
  1. Sub test()
  2. Dim filename As String
  3. Dim i As Integer
  4. For i = 1 To 2
  5. filename = Workbooks("book1.xls").Sheets("sheet1").Cells(i, 1).Value
  6. Workbooks.Open filename
  7. Next
  8. End Sub
½Æ»s¥N½X

TOP

¦^´_ 2# owen06


    ¥¦¥X²{  subscript out of range

   click "debug" ¥X²{¤U­z»yªk³Q highlight...

  filename = Workbooks("book8.xls").Sheets("Sheet1").Cells(i, 1).Value

   ÁÂÁÂ

TOP

¦^´_ 3# xoofer

§Ú¥t¥~§ï¤F¤U­±ªº¤è¦¡
µ²ªG¬Ovbatest1 Àɮ׶}¤F ,¦ý°j°é¶]²Ä¤G¦¸vbatest2 ®É¥¢±Ñ

¥i§_³Â·Ð«ü¾É¤@¤U¸Ó¦p¦ó­×¥¿

ÁÂÁÂ

Sub fpath()

Dim total As Integer
Dim fpath As String

Do While i < 3
i = i + 1

fpath = Cells(i, 1)
MsgBox (fpath)

Workbooks.Open (fpath)

Loop

End Sub

TOP

¦^´_ 4# xoofer

²¤°µ­×§ï¡A±z¸Õ¸Õ!!
  1. Sub fpath()
  2.     Dim total As Integer
  3.     Dim fpath As String
  4.    
  5.     For i = 1 To 2
  6.         fpath = ThisWorkbook.ActiveSheet.Cells(i, 1)
  7.         Workbooks.Open (fpath)
  8.     Next
  9. End Sub
½Æ»s¥N½X

TOP

¦^´_ 4# xoofer


    ¥ý»¡¤@¤Uworkbooks("xxxxx")§ì¤£¨ìªº­ì¦]¡AÀ³¸Ó¬O¦]¬°§A³o­ÓÀÉ¥u¬O¤@­Ó¼È®É·s¼WªºÀɮסA
    ¨Ã¥¼Àx¦s¦b¹q¸£¤¤¡A©Ò¥H¤~·|³y¦¨³oºØª¬ªp¡A¦pªG¬O¤w¸g¦³Àx¦sªºexcelªí¡A´N¤£·|¤F¡C
    ¦A¨Ó§A¨C¦¸ªº»yªk³£¦³¤@­Óª¼ÂI¡A´N¬O§A³£¨S¦³«ü©w¬O­n­þ¤@­ÓÀɮתº¬Y®æ­È¡A©Ò¥H§AÁöµM¶}¤F²Ä¤@­ÓÀÉ®×vbatest1¡A
    ¦ý¬O¨t²Î¤w¸g¸õ¶}¤F§A­ì¥»ªºÀɮסA¦Ó°õ¦æ¨ìvbatest1¤W¤F¡A¦ývbatest1¤W¨Ã¨S¦³§A·Q­nªº¸ô®|¡A©Ò¥Hvbatest2´N¶}¤£¤F¤F¡C
    ©Ò¥H§A¦pªG­n¦b¤£¦PÀɮשΤu§@ªí¶¡¤Á´«°õ¦æªº®É­Ô¡A°O±o­nµ¹­Ó©ú½Tªº«ü¥O¡A¤~¤£·|³y¦¨²V¶Ã¡C
  1. Sub test()
  2. Dim filename As String
  3. Dim i As Integer
  4. For i = 1 To 2
  5. filename = ThisWorkbook.Sheets("sheet1").Cells(i, 1).Value
  6. Workbooks.Open filename
  7. Next
  8. End Sub
½Æ»s¥N½X

TOP

¦^´_ 6# owen06

·PÁ«ü¾É

»yªk¥i¦æ¤F

TOP

        ÀR«ä¦Û¦b : ­×¦æ­nô½t­×¤ß¡AÂǨƽm¤ß¡AÀH³B¾i¤ß¡C
ªð¦^¦Cªí ¤W¤@¥DÃD