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

GetOpenFilenameªº»yªk°ÝÃD

GetOpenFilenameªº»yªk°ÝÃD

¤p§Ì³Ìªñ¦b¨Ï¥ÎGetOpenFilename®Éµo¥Í¤F¤@¨Ç°ÝÃD¤@ª½µLªk±Æ°£¡A
¥H¤U¬O§ÚºI¨ú¤F§Úµ{¦¡½Xªº³¡¤À¡A
¥Ø«e¤p§Ì¹J¨ìªº°ÝÃD´N¬O§Ú¦b§PÂ_FO¦b¶}±ÒÂÂÀɮɭY«ö¤U¨ú®ø·|¥X²{¿ù»~¡A
­Y§Ú¦bIf UBound(FO) > File_qty Then«e­±¦A¥[¤JIf FO = False Then¨Ó§PÂ_®É¥i¥H¸Ñ¨M¡A
¦ý­Y§Ú¹ê»Ú¦³¸ü¤JÀɮ׮ɴN·|µo¥Í«¬ºA¤£²Åªº°ÝÃD¡A¦ÓµLªkÄ~Äò«á­±ªºµ{¦¡¡A½Ð¦U¦ì¤j¤jÀ°§Ú¸Ñ´b¤@¤U¡AÁÂÁ¡C

    File_qty = Sheets(SN_1).Cells(2, 6)
    FO = Application.GetOpenFilename("Excel File(*.CSV) (*.CSV),(*.CSV)", , , , True)

    If UBound(FO) > File_qty Then
   
        MsgBox ("¸ü¤JÀɮפj©ó" & File_qty & "­Ó¤w¶W¥Xµ{¦¡¤W­­¡A½Ð­«·s¿ï¾ÜÀÉ®×»P½T»{¸ü¤J¼Æ¶q¬O§_¤p©ó©Îµ¥©ó" & File_qty & "­Ó¡AÁÂÁÂ!!")
        Sheets(SN_1).Select
   
    Else
   
        For I = 1 To UBound(FO)
            Sheets(SN_2).Select
            WB = ActiveWorkbook.Name
            WS = ActiveSheet.Name
            Workbooks.Open Filename:=FO(I), ReadOnly:=False, Notify:=False
            FN = ActiveWorkbook.Name
            SN = ActiveSheet.Name
            Range("A1:O15").Copy
            Windows(WB).Activate
            Sheets(SN_2).Cells(1, 1).Select
            Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
            NN = [A65536].End(xlUp).Row
            Windows(FN).Activate
            ActiveWorkbook.Close SaveChanges:=False
            Windows(WB).Activate
            ID = Cells(2, 3)
            T = Split(Trim(Cells(3, 3)), " ")
            Range(Cells(7, 1), Cells(NN, 15)).Copy
            Sheets("LED´ú¸Õµ²ªG").Select
            Cells((I - 1) * 20 + 8, 1).Select
            Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
            Cells((I - 1) * 20 + 4, 2) = Mid(ID, 1, Len(ID) - 4)
            Cells(I + 4, 20) = Mid(ID, 1, Len(ID) - 4)
            Cells((I - 1) * 20 + 5, 2) = T(0)
            Cells((I - 1) * 20 + 6, 2) = T(1) & " " & T(2)
        Next I
        Sheets("LED´ú¸Õµ²ªG").Select
        Application.Run ("Calculate_Mcd")
            
    End If

¦^´_ 1# doom834
UBound(FO)-> FO ¥²¶·¬O°}¦C ,  GetOpenFilename ¤èªk  ¥u¶Ç¦^¿ï¨úÀɮצWºÙ ¨S¦³¶Ç¦^°}¦C

¸Õ¸Õ¬Ý
  1. Sub Ex()
  2. Dim File_qty As Integer, SN_1 As String, i As Integer
  3. File_qty = Sheets(SN_1).Cells(2, 6)
  4. With Application.FileDialog(msoFileDialogOpen)
  5. .InitialFileName = "d:\" '«ü©w¶}±Òªº¸ô®|
  6. .Filters.Clear
  7. .Filters.Add "Excel File", "*.csv; *.txt; *.xls", 1
  8. .Filters.Add "*.*", "*.*", 2
  9. .FilterIndex = 1
  10. .Show
  11. If .SelectedItems.Count > File_qty Then
  12. MsgBox ("¸ü¤JÀɮפj©ó" & File_qty & "­Ó¤w¶W¥Xµ{¦¡¤W­­¡A½Ð­«·s¿ï¾ÜÀÉ®×»P½T»{¸ü¤J¼Æ¶q¬O§_¤p©ó©Îµ¥©ó" & File_qty & "­Ó¡AÁÂÁÂ!!")
  13. Sheets(SN_1).Select
  14. Else
  15. For i = 1 To .SelectedItems.Count
  16. MsgBox .SelectedItems(1)
  17. Next
  18. End If
  19. End With
  20. End Sub
½Æ»s¥N½X

TOP

GB¤j¤j¯u±j¡A
§Ú´N¥d¦bFO¦³Åª¨úÀɮ׮ɬO°}¦C»P«ö¤U¨ú®ø®É«¬ºA¤£²Å¦Ó¥d¦í¡A
Åý§Ú¾Ç²ß¨ì¤£¦Pªº¼gªk¤F~~·PÁÂGB¤j¤jªº«ü¾É!!!

TOP

        ÀR«ä¦Û¦b : ÀR§¤±`®¦¤v¹L¡B¶¢½Í²ö½×¤H«D¡C
ªð¦^¦Cªí ¤W¤@¥DÃD