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

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

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

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

Sub ¶}±ÒÀÉ®×()
Dim name, i, x, oldname
oldname = ThisWorkbook.Name
Range("A1").Select
x = InputBox("¼Æ¶q")

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


·PÁÂ!

½Ð°Ý§Ú·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

¦^´_ 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

©êº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

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

TOP

¦^´_ 5# koplkjnm
°t¦X 1# ÀɮצWºÙ¬° y(i)-->y(1),y(2),y(3),...   ³o¬°°}¦C
¦p y = Array("abc", "acc", "qqq", "aaa", "ccc")
y(1)="abc"
y(2)="acc"
y(3)="qqq"

4# ¥i§ï
  1. Sub Ex()
  2.     Dim A As Variant, i As Integer, x As Integer
  3.     x = InputBox("Àɮ׼ƶq")
  4.     For i = 1 To x
  5.         Range("A" & i).Select
  6.         '************************
  7.         'If I = 1 Then
  8.             'Range("A1").Select
  9.         'Else
  10.             'Range("A2").Select
  11.         'End If
  12.         '*****************************
  13.     Next
  14. End Sub '
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦^´_ 6# GBKEE

GBKEE¤j ©êºp¥i¯à§Úªº²z¸Ñ¸û®t
°£¤F­×§ï¬õ¦rªº¦a¤è,¨ä¥L¤£»Ý­×§ï¶Ü?
Range("A" & i).Select  ³o¦a¤è¤£¤Ó²M·¡·N«ä?
³Â·Ð§A¤F ÁÂÁÂ

Sub Ex()
    Dim A As Variant, i As Integer, x As Integer
    x = InputBox("Àɮ׼ƶq")
    For i = 1 To x
        Range("A" & i).Select
        '************************
        'If I = 1 Then
            'Range("A1").Select
        'Else
            'Range("A2").Select
        'End If
        '*****************************
    Next
End Sub '

TOP

¦^´_ 7# koplkjnm
  1. Option Explicit
  2. Sub ¤å¦rÀÉ®×()
  3. Dim txt_name, i, x, oldname
  4. oldname = ThisWorkbook.Name
  5. Range("A1").Select
  6. x = InputBox("Àɮ׼ƶq")
  7. For i = 1 To x
  8.   txt_name = i & ".txt"
  9.     Workbooks.OpenText Filename:=ThisWorkbook.Path & "\" & txt_name, Origin:=950 _
  10.         , StartRow:=1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _
  11.         ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, Comma:=False _
  12.         , Space:=False, Other:=False, FieldInfo:=Array(Array(1, 1), Array(2, 1), _
  13.         Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1), Array(7, 1), Array(8, 1), Array(9, 1), _
  14.         Array(10, 1)), TrailingMinusNumbers:=True
  15.         Windows(txt_name).Activate
  16.         '******³o¬qµ{¦¡µù¸Ñ±¼(¤£¥Î¤F)
  17.         'If i = 1 Then
  18.         'Range("A1").Select
  19.         'Else
  20.         ' Range("A2").Select
  21.         'End If
  22.         '***********************
  23.         Range("A" & i).Select
  24.         '·í=1 ¬°  Range("A1").Select
  25.         '·í=2 ¬°  Range("A2").Select   ¬O³o¼Ë¶Ü? ..............
  26.         
  27.     Next
  28. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦^´_ 8# GBKEE
GBKEE¤j §A¦n
¤U­±¬õ¦rªº¦a¤èÀ³¸Ó¨S¦³¿ù
¥i¬O³o¼Ëªº¸Ü·Pı¤W¥¦ÁÙ¬O·|·j´MÀɮצW¬°1.txt, 2.txt,...§@¶}±Òªº°Ê§@
¨S¿ìªk¶}±ÒÀɮצW¬°y(1), y(2),...
¦pªG§Ú±N¥¦§ï¦¨¹³ÂŦrªº³¡¤À¥i¥H¶Ü?
©ÎªÌ¬O­þ¸Ì­n¦A¸É¥R©Î­×§ïªº

³Â·Ð§A¤F ·PÁÂ

Option Explicit
Sub ¤å¦rÀÉ®×()
Dim txt_name, i, x, oldname
Dim y As  Variant
oldname = ThisWorkbook.Name
Range("A1").Select
x = InputBox("Àɮ׼ƶq")
For i = 1 To x
  txt_name = i & ".txt" '<--§ï¦¨   txt_name =y( 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

       Range("A" & i).Select
        '·í=1 ¬°  Range("A1").Select
        '·í=2 ¬°  Range("A2").Select   ¬O³o¼Ë¶Ü? ..............

        
    Next
End Sub

TOP

¦^´_ 9# koplkjnm
¦pªG§Ú±N¥¦§ï¦¨¹³ÂŦrªº³¡¤À¥i¥H¶Ü?
µ{¦¡¸Õ¤F¦³°ÝÃD¶Ü?
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

        ÀR«ä¦Û¦b : µoµÊ®ð¬Oµu¼ÈªºµoºÆ¡C
ªð¦^¦Cªí ¤W¤@¥DÃD