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

[µo°Ý] ±Æ§Ç«á§R°£¯S©wÄd¦ì

[µo°Ý] ±Æ§Ç«á§R°£¯S©wÄd¦ì


§e¤W¸ê®Æ­¶­±¡A½Ð°Ý¦pªG§Ú­n¥ý¥Hland_no_m©Mland_no_c¨âÄd¬°·Ç°µ±Æ§Ç¤§«á«O¯d¥H¤U³o¤E­ÓÄæ¦ì¨ä¥L§R°£¸Ó«ç»ò¼¶¼gVBA©O~·PÁÂ
(section) (SC) (LANDUSE)  (PUBNO)        (OPTION)        (METHOD)        (MUPLAN)        (DUPLAN)        (ORG_FID)

¦^´_ 12# billchenfantasy
®¦ ¸Õ¤F¤@¤U  #10 ªº¨â¦æ¶¶§Ç½Õ´«
µ²ªGÀ³¸Ó¸ò #11 ¤@¼Ë

TOP

@@¬Oªº¨C±iÄæ¦ì®æ¦¡³£¬O¤@¼Ëªº¡A©Ò¥Hland_no_m, land_no_c ¨C±iªí³£¦³¡A¥u¦³¤Ö¼Æ¤~¦³¦h¤@¦æªºª¬ªp¤~·|·Q»¡«ü©wÄæ¦ì¡A·PÁ±zªº¦A«×¨ó§U

TOP

¦^´_ 10# billchenfantasy
land_no_m, land_no_c ¨C±iªí³£¦³¶Ü?
  1.     If Not (IsError(Application.Match("land_no_m", .Rows(1), 0)) Or _
  2.             IsError(Application.Match("land_no_c", .Rows(1), 0))) Then
  3.         .[A1].CurrentRegion.Sort Key1:=.Columns(Application.Match("land_no_m", .Rows(1), 0)), _
  4.                                     Order1:=xlAscending, _
  5.                                     Key2:=.Columns(Application.Match("land_no_c", .Rows(1), 0)), _
  6.                                     Order2:=xlAscending, _
  7.                                     Header:=xlYes
  8.     Else
  9.         MsgBox .Sheets(i).Name & " : Sorting field not found."
  10.     End If
½Æ»s¥N½X

TOP

¹J¨ì°ÝÃD¤F@@¦pªG»Ý­n¥Hland_no_m¬°KEY1»Pland_no_c¬°KEY2¥h°µ±Æ§Ç¥H¤U±Æ§Çªºµ{§Ç¸Ó¦p¦ó­×§ï£z

If Not IsError(Application.Match("land_no_m", .Rows(1), 0)) Then .[A1].CurrentRegion.Sort Key1:=.Columns(Application.Match("land_no_m", .Rows(1), 0)), Order1:=xlAscending, Header:=xlYes

  If Not IsError(Application.Match("land_no_c", .Rows(1), 0)) Then .[A1].CurrentRegion.Sort Key1:=.Columns(Application.Match("land_no_c", .Rows(1), 0)), Order1:=xlAscending, Header:=xlYes

TOP

·P¿E~µù¸Ñ¸Ô²Ó~·Pı¤W¤F¤@½Ò@@ÁÂÁ±zªº¸Ñµª

TOP

¦^´_ 7# billchenfantasy
  1. Private Sub CommandButton1_Click()
  2. Dim Source, f
  3. Dim rng As Range

  4. '¥i¿ï¾Ü¦h­ÓÀÉ®×
  5. Source = Application.GetOpenFilename(FileFilter:="Excel Files (*.xls; *.xlsx),*.xls;*.xlsx", _
  6.                                     MultiSelect:=True)
  7. If TypeName(Source) = "Boolean" Then If Source = False Then Exit Sub

  8. For Each f In Source
  9. '¶}±ÒÀÉ®×/¬¡­¶Ã¯
  10. With Workbooks.Open(f)
  11.     '¹ï©Ò¦³¤u§@ªí
  12.     For i = 1 To ActiveWorkbook.Sheets.Count
  13.         '½Æ»s¤u§@ªí¨ì¥»¬¡­¶Ã¯
  14.         .Sheets(i).Copy after:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count)
  15.         '¥»¬¡­¶Ã¯¤¤¸Ó¤u§@ªí
  16.         With ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count)
  17.            '¨Ìland_no_m, land_no_cÄæ±Æ§Ç
  18.             If Not IsError(Application.Match("land_no_m", .Rows(1), 0)) Then .[A1].CurrentRegion.Sort Key1:=.Columns(Application.Match("land_no_m", .Rows(1), 0)), Order1:=xlAscending, Header:=xlYes
  19.             If Not IsError(Application.Match("land_no_c", .Rows(1), 0)) Then .[A1].CurrentRegion.Sort Key1:=.Columns(Application.Match("land_no_c", .Rows(1), 0)), Order1:=xlAscending, Header:=xlYes
  20.             
  21.             '§ä¥X¤£²Å¦XªºÄæ
  22.             For j = 1 To .[A1].CurrentRegion.Columns.Count
  23.                 If IsError(Application.Match(.Cells(1, j).Value, Array("section", "SC", "LANDUSE", "PUBNO", "OPTION", "METHOD", "MUPLAN", "DUPLAN", "ORG_FID"), 0)) Then
  24.                     If rng Is Nothing Then Set rng = .Columns(j) Else Set rng = Union(rng, .Columns(j))
  25.                 End If
  26.             Next j
  27.             '§R°£
  28.             .Range(rng.Address).Delete shift:=xlToLeft
  29.             Set rng = Nothing
  30.         End With
  31.     Next i
  32.     'Ãö³¬ÀÉ®×
  33.     .Close
  34. End With
  35. Next f
  36. End Sub
½Æ»s¥N½X

TOP

·PÁÂstillfish00 ³o¹ï§Ú³oµæ³¾¨Ó»¡¡A¬Ý°_¨Ó²ª½¬OÅÜÅ]³N¡A·P®¦¡A¬O±zªº¶×¤J¤è¦¡¤ñ¸û¦X²z¡A
.Range("A:C,E:I,K,Q").Delete Shift:=xlToLeft¬Oª½±µ¿ï©wÄæ¦ì
³Ì«á¤@­Ó°ÝÃD¬O©Ò¿×"§R°£¯S©wÄd¦ì"¥i¥H¬O«ü©w«O¯d(section) (SC) (LANDUSE) (PUBNO) (OPTION) (METHOD) (MUPLAN) (DUPLAN) (ORG_FID)¼ÐÃDªº¤@¾ã­ÓÄæ¦ì¡A¨ä¥LµL½×¬Æ»ò¼ÐÃDªºÄæ¦ì³£§R±¼ªº¼gªk¶Ü(¥Î¥H½T«O§å¦¸®É¬Y¤@­ÓÀɪº¨Ò¥~¦h¤@±øµL¶·«O¯dªºÄd¦ì)

TOP

¦^´_ 5# billchenfantasy
¦P¤@¬¡­¶Ã¯¬O¤£¯à¦³¦h­Ó¬Û¦P¦WºÙªº¤u§@ªí

§A­nªº§å¦¸³B²z¬O³o¼Ë¶Ü? (¥i¿ï¦h­ÓÀÉ®×)
  1. Private Sub CommandButton1_Click()
  2. Dim Source, f

  3. '¥i¿ï¾Ü¦h­ÓÀÉ®×
  4. Source = Application.GetOpenFilename(FileFilter:="Excel Files (*.xls; *.xlsx),*.xls;*.xlsx", _
  5.                                     MultiSelect:=True)
  6. If TypeName(Source) = "Boolean" Then If Source = False Then Exit Sub

  7. For Each f In Source
  8. '¶}±ÒÀÉ®×/¬¡­¶Ã¯
  9. With Workbooks.Open(f)
  10.     '¹ï©Ò¦³¤u§@ªí
  11.     For i = 1 To ActiveWorkbook.Sheets.Count
  12.         '½Æ»s¤u§@ªí¨ì¥»¬¡­¶Ã¯
  13.         .Sheets(i).Copy after:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count)
  14.         '¥»¬¡­¶Ã¯¤¤¸Ó¤u§@ªí
  15.         With ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count)
  16.            '¨ÌE,FÄæ±Æ§Ç
  17.            .[A1].CurrentRegion.Sort Key1:=.[E:E], Order1:=xlAscending, _
  18.                                     Key2:=.[F:F], Order2:=xlAscending, _
  19.                                     Header:=xlYes
  20.            '§R°£¤£­nªºÄæ
  21.            .Range("A:C,E:I,K:L,Q:Q").Delete Shift:=xlToLeft
  22.         End With
  23.     Next i
  24.     'Ãö³¬ÀÉ®×
  25.     .Close
  26. End With
  27. Next f
  28. End Sub
½Æ»s¥N½X

TOP

@@Private Sub CommandButton2_Click()
ªºOK¤F¹ï©ó±zªº¸Ñµª·PÁ¸U¤À¡A§Ú¨Ó¦n¦n¬ã¨s¤@¤U
Private Sub CommandButton1_Click()ªº·N«ä¬O»¡
"½Æ»s¤u§@ªí¹L¨Ó®É¦W¦rÀ³¸Ó¬O©M­ì¥»¤u§@ªí¤@¼Ëªº"¨S¿ù
¦]¬°§ÚªºÀɮצ³«Ü¦h¡A¦Ó¥BÁöµM¤º®e®æ¦¡¤@¼Ë¦ýÀɦW¤£¤@¼Ë¡A§Úªº·Qªk¬O­n«ç»ò¼Ë
§â¤£¦PÀɦWªºÀɮ׶׶i¨Ó¤§«á³£¥i¥H°õ¦æPrivate Sub CommandButton2_Click()¡A
¦]¬°«ü©wªºWith Sheets("¤u§@ªí¦WºÙ")¤u§@ªí¦WºÙ·|ÅÜ
µ¥³o­Ó³£¤F¸Ñ¤F±µ¤U¨Ó¦A·Q¤U¤@¨B«ç»ò§å¦¸
¦A¦¸ÁÂÁ§A¼Ú

TOP

        ÀR«ä¦Û¦b : ¦³®É·í«äµL®É­W¡A¦n¤Ñ­n¿n«B¨Ó³¡C
ªð¦^¦Cªí ¤W¤@¥DÃD