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

[µo°Ý] ¦p¦ó±N¶W¹L65536µ§¥H¤Wªº¸ê®Æ©ñ¤J¬¡­¶Ã¯(¤w¸Ñ¨M^^)

[µo°Ý] ¦p¦ó±N¶W¹L65536µ§¥H¤Wªº¸ê®Æ©ñ¤J¬¡­¶Ã¯(¤w¸Ñ¨M^^)

¥»©«³Ì«á¥Ñ ¤Ú§J´µ ©ó 2011-5-28 09:06 ½s¿è

EX:
¤å¦rÀÉ: test.txt (µ§¼Æ·|¶W¹L65536,Á`µ§¼Æ:¥¼ª¾)

§Æ±æµ{¦¡¨Ì§Ç±N65536µ§¸ê®Æ©ñ¤J¦U¤u§@ªí
sheet1   1-65536µ§
sheet2   65537-131072µ§
sheet3   ...¥H¦¹Ãþ±À¨ì³Ì¥½µ§

½Ð±Ð¶·¦p¦ó°µ¸û§Ö³t?

ÁÂÁ¨â¦ìªO¥DªºÀ°¦£
¨âºØ¤è¦¡³£¦¨¥\¤F
¤ñ§Ú­ì¨Ó¤gªk·Ò¿û§Ö³t«Ü¦h
¤]¾Ç²ß¨ìºë²ªºµ{¦¡¼gªk
^^

TOP

¦^´_ 4# ¤Ú§J´µ
Sub yy()
'¤Þ¥ÎMicrosoft Scripting Runtime



¤£¤Þ¥ÎMicrosoft Scripting Runtimeªº¼gªk
  1. Sub Ex()
  2.     Dim MyString As String, i As Long, Sh As Integer, Ar
  3.     Open "d:\test\test.txt" For Input As #1    ' ¶}±Ò¿é¤JÀÉ¡C
  4.     i = 1
  5.     Sh = 1
  6.     ReDim Ar(1 To Rows.Count)
  7.     Do While Not EOF(1)              ' Àˬd¬O§_¤w¨ìÀɧÀ¡C
  8.         If i > Rows.Count Then       'Rows.Count¬°¦CªºÁ`¼Æ 2003ª©¥»->65536
  9.             Sheets(Sh).Range("a:a") = Application.Transpose(Ar)
  10.             ReDim Ar(1 To Rows.Count)
  11.             i = 1
  12.             Sh = Sh + 1
  13.             If Sh > Sheets.Count Then Sheets.Add after:=Sheets(Sheets.Count)
  14.         End If
  15.         Line Input #1, MyString      ' ±N¸ê®ÆŪ¤JÅܼƤ¤¡C
  16.         Ar(i) = MyString
  17.         i = i + 1
  18.     Loop
  19.     Sheets(Sh).Range("a:a") = Application.Transpose(Ar)
  20.     Close #1
  21. End Sub
½Æ»s¥N½X

TOP

¥»©«³Ì«á¥Ñ ¤Ú§J´µ ©ó 2011-5-28 09:03 ½s¿è

ÁÂÁª©¥D¦^ÂÐ
°õ¦æ«áµo¥Í¿ù»~°T®§
½sĶ¿ù»~: ¨Ï¥ÎªÌ¦Û­q«¬ºA©|¥¼©w¸q

°»¿ù¬°
    Dim fso As Scripting.FileSystemObject
   Dim myTxt As Scripting.TextStream

³Â·Ðª©¥D¬Ý¬Ý¬O§_¥i­×­q,ÁÂÁÂ

TOP

  1. Sub yy()

  2. '¤Þ¥ÎMicrosoft Scripting Runtime

  3. Application.ScreenUpdating = False
  4.            
  5.     Dim fso As Scripting.FileSystemObject
  6.     Dim myTxt As Scripting.TextStream
  7.     Dim myfile As String, myname$
  8.     Dim i As Long, j%
  9.    
  10.     ActiveSheet.Cells.Clear
  11.     myfile = Application.GetOpenFilename("text files (*.txt),*.txt", , "°O¨Æ¥»¤å¥ó")  '¿ï¾Ü¤å¥ó¦W
  12.     Set fso = New Scripting.FileSystemObject
  13.     Set myTxt = fso.OpenTextFile(Filename:=myfile, IOMode:=ForReading)
  14.     With myTxt
  15.         i = 1: j = 1: myname = "sheet" & j
  16.         Do Until .AtEndOfStream
  17.            Sheets(myname).Cells(i, 1) = .ReadLine
  18.                      
  19.                       i = i + 1
  20.            If i = 65530 Then
  21.                j = j + 1
  22.                If j > 3 Then
  23.                     Sheets.Add after:=Sheets(myname)
  24.                End If
  25.                myname = "sheet" & j
  26.                i = 1
  27.            End If
  28.         Loop
  29.         .Close
  30.     End With

  31. End Sub
½Æ»s¥N½X
¨S¤å¥ó¥i´ú¸Õ¡A§A¦Û¤v´ú¸Õ¤@¤U§a

TOP

¦^´_ 1# ¤Ú§J´µ
¥i§_¶Ç¤Wµ§¼Æ¤Ö©ó65536 ªºµ{¦¡½X,¨Ó¬Ý¬Ý¦p¦ó§ï.

TOP

        ÀR«ä¦Û¦b : ¤H¥Í¨S¦³©Ò¦³Åv¡A¥u¦³¥Í©Rªº¨Ï¥ÎÅv¡C
ªð¦^¦Cªí ¤W¤@¥DÃD