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

[µo°Ý] ¤å¦rÀɶ}±Ò

GBKEE¤j
©êºp ½Ð°Ý³o¬q¥Î·N¬O¤°»ò ³Â·Ð§A¤F  ÁÂÁÂ
    txt_name = Array("abc", "acc", "qqq", "aaa", "ccc")

TOP

©êºp§Ú¥i¯à¨S»¡²M·¡
¤U¤èªº»yªk¬O¥i¥H³sÄò¶}±Ò¦b¦P¤@­Ó¸ê®Æ§¨¤ºªº¤å¦rÀÉ 1.txt ,2.txt ,...
¨º°²¨Ï§Úªº¤å¦rÀɦW¬°y(1).txt, y(2).txt, ...
¨º½Ð°Ý§Ú­n¦p¦ó­×§ï
·PÁÂ

Sub ¤å¦rÀÉ®×()
Dim txt_name, i, x, oldname
oldname = ThisWorkbook.Name
Range("A1").Select
x = InputBox("Àɮ׼ƶq")

For i = 1 To x
  txt_name = i & ".txt"

    Workbooks.OpenText Filename:=ThisWorkbook.Path & "\" & txt_name, Origin:=950 _
        , StartRow:=1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _
        ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, Comma:=False _
        , Space:=False, Other:=False, FieldInfo:=Array(Array(1, 1), Array(2, 1), _
        Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1), Array(7, 1), Array(8, 1), Array(9, 1), _
        Array(10, 1)), TrailingMinusNumbers:=True
   
   Windows(txt_name).Activate
   If i = 1 Then
    Range("A1").Select
    Else
     Range("A2").Select
    End If
   
    Next

End Sub

TOP

¦^´_ 1# koplkjnm
¬O³o¼Ë¶Ü?
  1. Option Explicit
  2. Sub ¶}±ÒÀÉ®×()
  3. ' Name¬OVBA ªºÃöÁä¦r ½Ð¤£­nÅܼƦWºÙ
  4.     Dim i, x As Integer, txt_name
  5.     oldname = ThisWorkbook.name & "\"
  6.     Range("A1").Select
  7.     txt_name = Array("abc", "acc", "qqq", "aaa", "ccc")
  8.     Do
  9.         x = Application.InputBox("¼Æ¶q ¤£¥i > " & UBound(txt_name) + 1, Type:=1)
  10.     Loop Until x <= UBound(txt_name) + 1 Or x = 0
  11.     If x > 0 Then
  12.         For i = 1 To x
  13.             Workbooks.Open txt_name & txt_name(i) & ".txt"
  14.         Next
  15.     End If
  16. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

½Ð°Ý§Ú·Q­n¥Î¥¨¶°¶}±Ò¦h­Ó¤å¦rÀÉ
ÀɮצWºÙ¬° y(i)-->y(1),y(2),y(3),...
¨º¤U½X«ç»ò­×§ï

Sub ¶}±ÒÀÉ®× ...
koplkjnm µoªí©ó 2013-5-8 00:21


1. ¦³ For ¨S Next....
2.¶}°_«á¡H
3.¤å¥óÀɮצWºÙ¡H
4.Àɮשñ¸m¸ê®Æ§¨¦ó¦b¡H

  ¦h°µ¦h·Q¦h¾Ç²ß¡A¤Ö¬Ý¤Ö¿ù¤Ö°g³~

  ¦h°µ=¦h¦h½m²ß¡A¦h¦h½s¼g¡C
  ¦h·Q=·Q·Q¬°¤°»ò¤H®aµ{¦¡­n¨º¼Ë¼g¡A¦pªG´«¦¨¦Û¤v¡A¤S·|«ç¼g¡C
  ¦h¾Ç²ß=¾Ç²ß¤H®aªºµo°Ý¨Ã¸Ñµª¡A¾Ç²ß¤H®aªº¼gªk

  ¤Ö¬Ý=¥u¬Ý¤£°µ¤]ªPµM

TOP

        ÀR«ä¦Û¦b : ¤£­n¤p¬Ý¦Û¤v¡A¦]¬°¤H¦³µL­­ªº¥i¯à¡C
ªð¦^¦Cªí ¤W¤@¥DÃD