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

¸ê®Æ­åªR(TextToColumns)¹ï¶H¥i¥H¤£¬OÀx¦s®æ¶Ü?

¸ê®Æ­åªR(TextToColumns)¹ï¶H¥i¥H¤£¬OÀx¦s®æ¶Ü?

½Ð±Ð¦U¦ì«e½ú
Selection.TextToColumns
¨ä¤¤Selection¦ü¥G¤@©w­n¬Orange¡A¨º¦³¿ìªkª½±µ¹ï°}¦CÅܼƶi¦æ¸ê®Æ­åªR¶Ü?

ex:dim A(3) as double
A(0)="1,2,3"
·Q¤£³z¹Lsheet§â¸ê®Æ­åªR¦¨A(1)=2¡BA(2)=2¡BA(3)=3
¦³¿ìªk³o¼Ë°µ¶Ü?

ÁÂÁÂ

¦^´_ 1# chiata

°}¦C¨Ã¤£»Ý­n­åªR§Y¥iª½±µ¼g¤JÀx¦s®æ¤º
­Y§Aªº·N«ä¬O­n±N¥]§t¯S©w¤À¹j²Å¸¹ªº¤@ºû°}¦C¤¤ªº°}¦C¤¸¯À¤À¹j«áÅܦ¨¤Gºû°}¦C¼g¤JÀx¦s®æ
¨º»ò¥²¶·§Q¥Î°j°é¡A±N­ì°}¦C¨C­Ó¤¸¯À¨Ï¥ÎSplit¤èªk¤À³Î«á¼g¤J
­Y¤À³Î«áªº¤Gºû°}¦C¡A¨ä¨C¤@¦Cªº¤¸¯À­Ó¼Æ¤£¦P¡A«h¥²¶·¤@¦C¤@¦Cªº¼g¤J
­Y¤À³Î«áªº¤Gºû°}¦C¡A¨ä¨C¤@¦Cªº¤¸¯À­Ó¼Æ¬Û¦P¡A«h¥i¥H¤@¦¸ªº±N¾ã­Ó¤Gºû°}¦C³z¹L2¦¸ªºApplication.Transpose¼g¤J
¦ÓSplit¤èªk«áªº°}¦C¤¸¯À¡A¨ä¸ê®Æ«¬ºA«h¤@«ß¬°String(¦r¦ê)
¤j­P¤Wªºµ{§Çµ²ºc¦p¤U
For i=Lbound(a) to Ubound(a) '­ì°}¦C°j°é
   ar=Split(a(i),",")  '³rÂI¤À³Î°}¦C¤¸¯À¡A²£¥Í·sªº¤@ºû°}¦C
   Cells(i+1,1).Resize(,Ubound(ar)+1)=ar  '±N¤@ºû°}¦C¼g¤J
Next
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

¦^´_ 2# Hsieh


ÁÂÁÂH¤j¡AÀ³¸Ó»¡§Ú·|¿é¤J¤@µ§¸ê®Æ¡A¦¹¸ê®Æ¥i¯à¦³¨âºØ§ÎºA¡A²Ä¤@ºØ¬O¯Â¼Æ¦r¡Fex:1 or 5 ...¡A²Ä¤GºØ¬O¦r¦ê¡Fex:1,3,5¡A
¦pªG¸ê®Æ¬O¦r¦êªº¸Ü§Ú´N¥Î§â¥¦¤À³Î«á¥á¶i°}¦C¸Ì¡A­ì¥»§Ú·|§â¥¦¥á¤J¬Y­ÓÀx¦s®æ¤¤¡A¦b¨Ï¥Î¸ê®Æ­åªR(TextToColumns)°µ¤À³Î«á¦AŪ¶i°}¦C¤¤¡A
¤§«á­pºâ´Nª½±µ¥Î°}¦C¡A¤£·|¨Ï¥Î¨ìÀx¦s®æ¡C
²{¦b¨Ï¥ÎSplit´N¥i¥H¤£¥Î¸ê®Æ­åªR¸òÀx¦s®æ¹F¨ì¬Û¦P®ÄªG¤F!ÁÂÁ¡C

TOP

¦^´_ 2# Hsieh

¦ÓSplit¤èªk«áªº°}¦C¤¸¯À¡A¨ä¸ê®Æ«¬ºA«h¤@«ß¬°String(¦r¦ê)




¦p¤W¹Ï¡A¦ü¥G¨Ï¥ÎSplit«ábbÁÙ¬O¦r¦ê«¬ºA¦Ó¤£¬O°}¦C?
¥B¨Ï¥Îval¤]¤£ªk±N¨ä§ï¦¨¼Æ¦r«¬ºA¡A­n´«¤@­ÓÅܼƤ~¯à¥Îval§ï¦¨¼Æ¦r«¬ºA¡C
ÁöµM»¡¦r¦ê¤]¯à°µ¼Æ¾Ç¹Bºâ´N¬O¤F¡C

TOP

¦^´_ 4# chiata

¦b2#¦^ÂФ¤¤w¸g»¡©úSPLIT©Ò±o¨ìªº¬O¦r¦ê«¬ºAªº°}¦C
¦Ó°}¦CµLªk§ïÅܨä¸ê®Æ«¬ºA¡A°ß¦³¥H¥t¤@¸ê®Æ«¬ºA°}¦CÀx¦s¤~¥i§ïÅܤ¸¯Àªº¸ê®Æ«¬ºA
  1. Sub ex()
  2. Dim ar()
  3. a = "1,3,5,7,9"
  4. bb = Split(a, ",")
  5. ReDim ar(UBound(bb))
  6. For i = 0 To UBound(bb)
  7. ar(i) = CDbl(bb(i))
  8. MsgBox ar(i) & "  IS  " & TypeName(ar(i))
  9. Next
  10. End Sub
½Æ»s¥N½X
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

¦^´_ 5# Hsieh

ÁÂÁ¡A§Ú²z¸Ñ¤F!
­è­è¨Ï¥Îµo²{¦r¦ê¥i¥H¹Bºâ¡A¦ý¤£¯à°µ<¡B=¡B>µ¥§PÂ_¡A¥u¯à­n§PÂ_®É¨Ï¥Îval©Î¬O¹³H¤j©Ò»¡ªº¦s¦¨¥t¤@­Ó°}¦C¨Ó¨Ï¥Î¡C

TOP

¥»©«³Ì«á¥Ñ GBKEE ©ó 2013-2-5 16:37 ½s¿è

¦^´_ 6# chiata
¨Ï¥Îµo²{¦r¦ê¥i¥H¹Bºâ¡A¦ý¤£¯à°µ<¡B=¡B>µ¥§PÂ_
  1. Option Explicit
  2. Sub Ex()
  3.     Dim A As String, B As Variant
  4.     A = "A5"
  5.     B = "10"
  6. '    MsgBox A * B   '** VBA ¶Ç¦^: ¿ù»~­È13  "«¬ºA¤£²Å¦X"
  7.     If IsNumeric(A) And IsNumeric(B) Then MsgBox A * B Else MsgBox "«¬ºA¤£²Å¦X"
  8.     A = "5"
  9.     B = "10"
  10.     If IsNumeric(A) And IsNumeric(B) Then MsgBox A * B Else MsgBox "«¬ºA¤£²Å¦X"
  11.     A = "1,2,3,4,5,6,7,8,9,10"
  12.     B = Split(A, ",")
  13.     MsgBox B(0) * B(UBound(B))
  14.     MsgBox B(0) < B(UBound(B))  '1 < 10 =True
  15.     MsgBox B(0) > B(UBound(B))  '1 > 10 =False
  16.     MsgBox B(0) = B(UBound(B))  '1 = 10 =False  
  17.     A = "1,2,3,4,5,6,7,8,9,A10"
  18.     B = Split(A, ",")
  19.     MsgBox B(0) * B(UBound(B))    '** VBA ¶Ç¦^: ¿ù»~­È13  "«¬ºA¤£²Å¦X"
  20. End Sub
½Æ»s¥N½X

TOP

¦^´_ 7# GBKEE
  1. Sub test()

  2.     For t = 1 To 110
  3.         If t <= "10" Then MsgBox t
  4.     Next t
  5.    
  6. End Sub
  7. Sub test2()

  8.     For t = 1 To 110
  9.         If t <= Val("10") Then MsgBox t
  10.     Next t
  11.    
  12. End Sub
½Æ»s¥N½X
¤p§Ì¹J¨ìªº°ÝÃD...test¥u¦³t=1¸ò10·|¸õmsgbox¥X¨Ó¡Atest2´Nt=1~10³£·|¸õ¡A¤£ª¾¹D¬O­þÃä¥X°ÝÃD...
ÁÂÁÂ

TOP

¦^´_ 8# chiata
§A¨S¦³«Å§i ÅܼÆtªº«¬ºA¬°¼Æ¦r,vba±Nµø¬° ¦r¦êªº¹ï¦r¦êªº¤ñ¹ï
  1. Option Explicit         '±j¨î»Ý«Å§iÅܼÆ
  2. Sub test()
  3.     Dim t As Integer
  4.     For t = 1 To 110
  5.         If t <= "15" Then MsgBox t
  6.     Next t   
  7. End Sub
  8. Sub test2()
  9.     Dim t As Variant  ' Variant ¸ê®Æ«¬ºA¬O©Ò¦³¨S³Q©ú½T«Å§i¬°¨ä¥L«¬ºA  **µ¥¦P¨S¦³«Å§iÅܼÆ***
  10.     For t = 1 To 110
  11.         If t <= "10" Then MsgBox t & " <= 10"
  12.         If t <= "20" Then MsgBox t & " <= 20"
  13.         If t <= "30" Then MsgBox t & " <= 30"
  14.     Next t
  15. End Sub
½Æ»s¥N½X

TOP

¦^´_ 9# GBKEE


   

ÁÂÁÂG¤j¡A·s¦~§Ö¼Ö¡A
¹Ï¤¤Variant/Integer¤£¬O¥Nªí¦¹Åܼƥثe¬OIntegerªºª¬ºA¶Ü¡H
§Ú¥H¬°Variant¬O¥ý°ð«ü©wÅܼƫ¬ºA¡A«Ýµ{¦¡°õ¦æ«á·|¦Û°Ê§PÂ_¦¹ÅܼƦX¾A«¬ºA¡A¨Ò¦pinteger¡Bstring...µ¥¡A¨Ï¥Î¤W¤ñ¸û¦³¼u©Ê¡C
ÁÙ¬O§ÚÆ[©À¿ù»~¡H¡H

TOP

        ÀR«ä¦Û¦b : §Ñ¥\¤£§Ñ¹L¡A§Ñ«è¤£§Ñ®¦¡C
ªð¦^¦Cªí ¤W¤@¥DÃD