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

[µo°Ý] ¸óÄæ¸m¤¤»PÂ^¨ú¤å¦r°ÝÃD

¦^´_ 1# v03586
¹Ï¤ù±K±K³Â³Â«ç¤£ªþÀÉ¡A­n¸Õªº¤H¦Û¤v¨Ì¹Ï¥h¶ñ¶Ü?
ªí¹F¤£²M¡BÃD·N¤£©ú½T¡B¨SªþÀɮ׮榡¡B¨S¦³°Q½×°ÝÃDªººA«×~~~~~~¥H¤W·R²ö¯à§U¡C

TOP

¦^´_ 4# v03586
Try this
4.¨Ì·ÓDÄæ¬Û¦Pªº¦r¦ê¥Î¶Â®Ø½u  => §ï¬°¨Ì¦X¨ÖªºAÄæµe²Ê®Ø
  1. Sub Test()
  2.     Dim oRegexp As Object: Set oRegexp = CreateObject("vbscript.regexp")
  3.     Dim ar, i, j, s
  4.    
  5.     ar = Sheets("³øªí").Range("A9:F21").Value  'or .Range("A9").CurrentRegion.Value
  6.    
  7.     With oRegexp
  8.         .Pattern = "^[^-]*-"
  9.         For i = 1 To UBound(ar)
  10.             If .Test(ar(i, 3)) Then ar(i, 3) = .Replace(ar(i, 3), "")
  11.         Next
  12.         .Pattern = "^[^-]*-[^-]*-"
  13.         For i = 1 To UBound(ar)
  14.             If .Test(ar(i, 4)) Then ar(i, 4) = .Replace(ar(i, 4), "")
  15.         Next
  16.         .Pattern = "^(.{2})(.)(.*)[a-zA-Z]$"
  17.         For i = 1 To UBound(ar)
  18.             If .Test(ar(i, 5)) Then
  19.                 s = .Replace(ar(i, 5), "$1-$2-$3")
  20.                 mch = Application.VLookup(s, Sheets("Flow").[A:B], 2, False)
  21.                 If Not IsError(mch) Then ar(i, 5) = mch
  22.             End If
  23.         Next
  24.         .Pattern = "(SPC|SCL).*$"
  25.         '¥t¤@ºØ QVS to SPC/SCL
  26.         '.Pattern = "^.*?(QVS.*?(SPC|SCL)).*$"
  27.         For i = 1 To UBound(ar)
  28.             If .Test(ar(i, 6)) Then ar(i, 6) = .Replace(ar(i, 6), "$1")
  29.         Next
  30.         
  31.     End With
  32.    
  33.     Application.ScreenUpdating = False
  34.     With Sheets.Add.[A1].Resize(UBound(ar), UBound(ar, 2))
  35.         .Value = ar
  36.         .Sort key1:=.Cells(1, 1), order1:=xlAscending, key2:=.Cells(1, 4), order2:=xlAscending
  37.         .Borders.LineStyle = xlContinuous
  38.         .Borders.Weight = xlThin
  39.         Application.DisplayAlerts = False
  40.         i = 1
  41.         For j = 1 To UBound(ar)
  42.             If .Cells(j, 2).Value <> .Cells(j + 1, 2).Value Then
  43.                 If i <> j Then Range(.Cells(i, 1), .Cells(j, 1)).Merge
  44.                 With .Cells(i, 1).MergeArea.Resize(, .Columns.Count)
  45.                     .Borders(xlEdgeTop).Weight = xlMedium
  46.                     .Borders(xlEdgeBottom).Weight = xlMedium
  47.                     .Borders(xlEdgeLeft).Weight = xlMedium
  48.                     .Borders(xlEdgeRight).Weight = xlMedium
  49.                 End With
  50.                 i = j + 1
  51.             End If
  52.         Next
  53.         Application.DisplayAlerts = True
  54.         
  55.         [B:B].Font.Size = 16
  56.         [C:D].Font.Size = 12
  57.         ActiveWindow.Zoom = 63
  58.         [A:F].EntireColumn.AutoFit
  59.         [A:B].HorizontalAlignment = xlCenter
  60.     End With
  61.     Application.ScreenUpdating = True
  62. End Sub
½Æ»s¥N½X
ªí¹F¤£²M¡BÃD·N¤£©ú½T¡B¨SªþÀɮ׮榡¡B¨S¦³°Q½×°ÝÃDªººA«×~~~~~~¥H¤W·R²ö¯à§U¡C

TOP

¦^´_ 7# v03586
  1. oRegexp : regular expression ¥¿«hªí¹F¦¡/¥¿³Wªí¥Üªk¡A¥Î¨Ó¬d§ä¡B´À´«¡B´£¨ú¡BÅçÃÒ¦r¦ê¡A
  2. ¡A¥i°Ñ¦Ò http://club.excelhome.net/thread-1128647-1-2.html ¾Ç²ß

  3. .Pattern = "^[^-]*-" ¥Î¨Ó³]©w³W«h
  4. ^ : ¦r¦ê¶}ÀY¦ì¸m
  5. [^-] : «D-ªº¥ô·N¦r¤¸
  6. [^-]* : 0~n­Ó«D-ªº¥ô·N¦r¤¸
  7. - : -¦r¤¸
  8. ©Ò¥H¬O¤Ç°t¶}ÀY¨ì²Ä¤@­Ó-¦r¤¸

  9. .Test ¬O¥Î¨Ó´ú¸Õ¬O§_²Å¦X³W«h
  10. .Replace ¬O§â²Å¦X³W«h³¡¤Àªº¦r¦ê¨ú¥N±¼
½Æ»s¥N½X
ªí¹F¤£²M¡BÃD·N¤£©ú½T¡B¨SªþÀɮ׮榡¡B¨S¦³°Q½×°ÝÃDªººA«×~~~~~~¥H¤W·R²ö¯à§U¡C

TOP

        ÀR«ä¦Û¦b : ¶¢¤HµL¼Ö½ì¡A¦£¤HµL¬O«D¡C
ªð¦^¦Cªí ¤W¤@¥DÃD