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

[µo°Ý] ½Ð°Ý¦U¦ì«e½úÃö©óVBA ¤¤¦r¦ê¨ú¥N°ÝÃD

[µo°Ý] ½Ð°Ý¦U¦ì«e½úÃö©óVBA ¤¤¦r¦ê¨ú¥N°ÝÃD

¦U¦ì«e½ú½Ð°Ý¤@¤U~¦pªþ¥ó¤¤¤p§ÌªºBÄ欰²M³æ¨Ó·½¡B¤p§Ì·Q­n¾ã²z±N»Ý­nªº¶µ¥Ø¥t¥~¾ã²z¥X¹³"C" & "D"Ä污ªp¡A
½Ð°Ý«e½ú­Ì¤p§Ì¸Ó¦p¦ó§ï¼g¤~¦³¿ëªk±o¥X©Ò»Ýªºµª®×©O¡H

¦A¦¸³Â·Ð¤j®a¤F¡BÁÂÁÂ~
±ø¥ó¦¡¨ú¥N test.rar (11.61 KB)

¥»©«³Ì«á¥Ñ stillfish00 ©ó 2014-6-9 20:11 ½s¿è

¦^´_ 1# ii31sakura
  1. Sub TEST()
  2.   Dim ar, s, oReg
  3.   
  4.   Set oReg = CreateObject("vbscript.regexp")
  5.   With oReg
  6.     .Global = True
  7.     .Pattern = "(\d+)-(\S+).*\*(\d+)"
  8.   End With
  9.   With Worksheets("data")
  10.     ar = .Range(.[B2], .Cells(.Rows.Count, "B").End(xlUp)).Value
  11.     ReDim Preserve ar(1 To UBound(ar), 1 To 2)
  12.     For i = 1 To UBound(ar)
  13.       s = ar(i, 1)
  14.       ar(i, 1) = oReg.Replace(s, "$1-$3")
  15.       ar(i, 2) = oReg.Replace(s, "$1-$2")
  16.     Next
  17.     .[C2].Resize(UBound(ar), UBound(ar, 2)).Value = ar
  18.   End With
  19. End Sub
½Æ»s¥N½X

TOP

¦^´_ 2# stillfish00

stillfish00«e½ú·PÁÂÀ°¦£~
¤p§Ì¥ý¦¬¤U«á¦A¨Ó¬ã¨s¤j¤j´£¨Ñªºµ{¦¡¨Ï¥Î¤è¦¡¡B
¦b¦¹¦A¦¸·PÁÂstillfish00«e½ú¤F~

TOP

¦^´_ 2# stillfish00

stillfish00«e½ú¡B¤£¦n·N«ä¯à¤£¯à½ÐÀ°¤p§Ì¬Ý¤@¤U¡A
¦]¤p§Ì¦b°õ¦æ¹Lµ{¤¤¦³¸I¨ì¯S®í¦r¦ê·|¥h¦Û°Ê²Õ¦X¦¨Ãþ¦ü¤é´Á®æ¦¡¡A
¦p"c"Äæ¤Ï¶À±¡ªp¡B½Ð°Ý¤p§Ì­n±q­þ¦p¦ó§ó§ï©O¡H

½Ð³Â·Ð¤@¤U¤F~·PÁ«e½ú


±ø¥ó¦¡¨ú¥N test1.rar (15.26 KB)

TOP

¦^´_ 4# ii31sakura
¥i¥H¥ý¿ïCÄæ¡A¥kÁäÀx¦s®æ®æ¦¡§ï¬°¤å¦r¦A¶]¡C
©Î¬Oµ{¦¡½X¸Ì·s¼W¤@¦æ§ï®æ¦¡
  1. Sub TEST()
  2.   Dim ar, s, oReg
  3.   
  4.   Set oReg = CreateObject("vbscript.regexp")
  5.   With oReg
  6.     .Global = True
  7.     .Pattern = "(\d+)-(\S+).*\*(\d+)"
  8.   End With
  9.   With Worksheets("data")
  10.     ar = .Range(.[B2], .Cells(.Rows.Count, "B").End(xlUp)).Value
  11.     ReDim Preserve ar(1 To UBound(ar), 1 To 2)
  12.     For i = 1 To UBound(ar)
  13.       s = ar(i, 1)
  14.       ar(i, 1) = oReg.Replace(s, "$1-$3")
  15.       ar(i, 2) = oReg.Replace(s, "$1-$2")
  16.     Next
  17.     With .[C2].Resize(UBound(ar), UBound(ar, 2))
  18.       .NumberFormatLocal = "@"  'Àx¦s®æ®æ¦¡§ï¬°¤å¦r
  19.       .Value = ar
  20.     End With
  21.   End With
  22. End Sub
½Æ»s¥N½X

TOP

¦^´_ 5# stillfish00

·PÁÂstillfish00«e½úªº«ü¾É¡B­ì¨Ó§â¥¦§Ë¦¨¤å¦r´N¤£·|¦Û°Ê¦ê±µ¤F°Ú¡A
·PÁÂÀ°¦£®@~

TOP

¦^´_ 5# stillfish00

stillfish00«e½ú¤£¦n·N«ä¡B½Ð±z«ü¾É¤@¤U¤p§Ì¡B­ì¥ýªº¨Ò¤l¬O±qBÄæ¦ì¥h©î¦¨C»PDÄ檺µ²ªG¡A¤p§Ì¸I¨ì¥t¥~¤@­Ó¨Ò¤l¬OÃþ¦üªº±¡ªp¡B
¦ý«o¬O±qCÄæ»PDÄæ¥h¦X¦¨BÄ檺±¡ªp¡A¯à§_½Ð«ü¾É¤@¤U¤p§Ì«e½úªº¨Ò¤lµ{¦¡¦p¦ó§ï¼g©O¡H
¦]¤p§Ì¸Õ¤F¦n´X¤ÑÁÙ¬O·Q¤£³z¦p¦ó­Ë±À¦^¥h«e½úªºµ{¦¡­ì²z¡C

½Ð³Â·Ð«e½ú¤@¤U¤F~

TOP

¥»©«³Ì«á¥Ñ stillfish00 ©ó 2014-6-20 15:16 ½s¿è

¦^´_ 7# ii31sakura
  1. Sub TEST2()
  2.   Dim ar, ar1, ar2, i, j
  3.   
  4.   With Worksheets("data")
  5.     ar = .Range(.[C2], .Cells(.Rows.Count, "D").End(xlUp)).Value
  6.     For i = 1 To UBound(ar)
  7.       ar1 = Split(ar(i, 1), vbLf): ar2 = Split(ar(i, 2), vbLf)
  8.       If UBound(ar1) <> UBound(ar2) Then MsgBox "Error : ¥X²{Àx¦s®æ¤º¦æ¼Æ¤£¤@­P": End
  9.       For j = LBound(ar1) To UBound(ar1)
  10.         If Split(ar1(j), "-")(0) <> Split(ar2(j), "-")(0) Then MsgBox "Error : ¥X²{½s¸¹¤£¤Ç°t": End
  11.         ar1(j) = ar2(j) & String(5, " ") & "·lÃa*" & Split(ar1(j), "-")(1)
  12.       Next
  13.       ar(i, 1) = Join(ar1, vbLf)
  14.     Next
  15.     ReDim Preserve ar(1 To UBound(ar), 1)
  16.     .[B2].Resize(UBound(ar)) = ar
  17.   End With
  18. End Sub
½Æ»s¥N½X

TOP

¦^´_ 8# stillfish00

·PÁÂstillfish00«e½ú~µ{¦¡¤¤¸Ì­±¤]¦³¬Ý¨ì´£¨Ñ¨¾§b½T»{¡A
«Ü·PÁ«e½úªº¼ö¤ßÀ°¦£~
   ÁÂÁÂ~

TOP

        ÀR«ä¦Û¦b : ¤ß¤¤±`¦sµ½¸Ñ¡B¥]®e¡B·P«ä¡Bª¾¨¬¡B±¤ºÖ¡C
ªð¦^¦Cªí ¤W¤@¥DÃD