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

[µo°Ý] EXCEL VBA ªº°ÝÃD

ÁÂÁ¡A½Ð±Ð¡AVBAªºµe­±¤¤¡A±z¦³¨Ï¥Î§Y®ÉºÊ¬Ýµøµ¡¨Ó»²§U±zªºµ{§Çª½¦æ¶Ü

TOP

¦^´_ 11# idnoidno

§Ú¤]¥u¬O¤@­Óªì¾ÇªÌ¡C¦³ªÅ®É§Ú·|¨Ó³o°Q½×°Ï¬Ý¬Ý¨ä¥L¤j¤jªºµ{¦¡ªº°µªk¡C¶¶«K¥H¨ä¥L¤Hªº°ÝÃD¨Ó·í¦¨§@·~¨Ó§@¡A¬Ý¬Ý¦Û¤v¾Ç¤F¦h¤Ö(¨ä¹ê¦³«Ü¦h¤H°ÝÃD¬Ý³£¬Ý¤£À´)¡A©Ò¥H§Ú¤]·|µ¥¨ä¥L¤j¤jªºµª®×°Õ¡I©Ò¥H¤j®a¤@°_¬ã¨s

TOP

¦^´_ 11# idnoidno

¬O³o¤@¦C¶Ü¡H
RngRow = ¤u§@ªí1.Columns(Rng.Column).Find("*", , , , , xlPrevious).Row '´M§ä§ïÄ檺³Ì«á¤@­ÓÀx¦s®æ
¨ä¤¤¡A¤u§@ªí1.Columns(Rng.Column)¬O´M§äªº½d³ò©Ò¹ïÀ³ªºÄæ¡A§Ú¥H°ÊºA´`Àô¨Ó§ïÅÜ¥¦´M§äªº½d³ò¡A¥H´`Àôªº²Ä¤@¦¸°j°é¨Ó»¡¡A¥¦·|·j´M"¥Ò"¨º¤@Äæ³Ì«á¦³"­È"ªºÀx¦s®æ¨Ó¶Ç¦^©Ò¹ïÀ³ªº¦C¸¹Row¡A§Ú¥H¸U¥Î¦r¤¸ * ¨Ó¥Nªí¥ô¦ó¦r¦ê¡AxlPrevious¬O¥Ñ¤U©¹¤W§ä,

  ¥H¤U¬OÂ^¨úExcel»¡©úRange.Findªº»¡©úµ¹°Ñ¦Ò¡I
Excel ¶}µo¤H­û°Ñ¦Ò¸ê®Æ
Range.Find ¤èªk
·|´M§ä½d³ò¤¤ªº¯S©w¸ê°T¡C
»yªk

¹Bºâ¦¡.Find(What, After, LookIn, LookAt, SearchOrder, SearchDirection, MatchCase, MatchByte, SearchFormat)

¹Bºâ¦¡   ¥Nªí Range ª«¥óªºÅܼơC

°Ñ¼Æ

¦WºÙ ¥²­n/¿ï¥Î ¸ê®ÆÃþ«¬ ´y­z
What ¥²­n Variant ­n·j´Mªº¸ê®Æ¡C¥i¥H¬°¦r¦ê©Î¥ô¦ó Microsoft Excel ¸ê®ÆÃþ«¬¡C
After ¿ï¥Î Variant «ü©wÀx¦s®æ¡A·j´M±N·|±q³o­ÓÀx¦s®æ¤§«á¶}©l¡C³o­ÓÀx¦s®æ¹ïÀ³©ó±q¨Ï¥ÎªÌ¤¶­±°õ¦æ·j´M®Éªº§@¥ÎÀx¦s®æ¦ì¸m¡Cª`·N¡AAfter ¥²¶·¬O½d³ò¤¤ªº³æ¤@Àx¦s®æ¡C½Ð°O¦í·j´M¬O±q³o­ÓÀx¦s®æ¤§«á¶}©l¡A¦]¦¹¥²¶·µ¥¨ì¸Ó¤èªk´`Àô¦^¨ì«ü©wªºÀx¦s®æ®É¡A¤~·|·j´M¨ä¤º®e¡C¦pªG¨S¦³«ü©w³o­Ó¤Þ¼Æ¡A«h·j´M·|±q½d³ò¥ª¤W¨¤ªºÀx¦s®æ¤§«á¶}©l¡C
LookIn ¿ï¥Î Variant ¸ê°TªºÃþ«¬¡C
LookAt ¿ï¥Î Variant ¥i¥H¬°¤U¦C¨ä¤¤¤@­Ó XlLookAt ±`¼Æ¡GxlWhole ©Î xlPart¡C
SearchOrder ¿ï¥Î Variant ¥i¥H¬°¤U¦C¨ä¤¤¤@­Ó XlSearchOrder ±`¼Æ¡GxlByRows ©Î xlByColumns¡C
SearchDirection ¿ï¥Î XlSearchDirection ·j´M¤è¦V¡C
MatchCase ¿ï¥Î Variant ¦pªG¬° True¡A«h·j´M®É·|±N¤j¤p¼gµø¬°¬Û²§¡C¹w³]­È¬° False¡C
MatchByte ¿ï¥Î Variant ¥u¦³·í±z¤w¿ï¨ú©Î¦w¸ËÂù¦ì¤¸²Õ»y¨¥¤ä´©®É¡A¤~¯à¨Ï¥Î¡C¦pªG¬° True¡A«hÂù¦ì¤¸²Õ¦r¤¸¥u¯à²Å¦XÂù¦ì¤¸²Õ¦r¤¸¡C¦pªG¬° False¡A«hÂù¦ì¤¸²Õ¦r¤¸¥i²Å¦X¹ïÀ³ªº³æ¦ì¤¸²Õ¦r¤¸¡C
SearchFormat ¿ï¥Î Variant ·j´M®æ¦¡¡C

TOP

¦^´_ 9# lpk187

·Q´N±Ð¡A§Aªº²Ä3¦æªº»yªk¡A¬O§_¥i¥Hµy°µ»¡©ú¤@¤U
ÁÂÁÂ

TOP

«zÁÂÁª©¥D¥X¤â¦^À³
¤p§Ì¤~¾Ç²Ê²L¡A¥i¯à­n¦n¦nªº¬ãŪ¤F
ÁÙ¬O¤Q¤À·PÁª©¥D

TOP

¦^´_ 7# idnoidno


    ­n¦p¦ó½u¤W¡A§Ú¤£·|­C¡I

TOP

¦^´_ 6# lpk187
  1. Sub ex()
  2. Dim Ar()
  3. Dim A As Range
  4. With ¤u§@ªí1
  5. For Each A In .Range(.[B1], .[B1].End(xlToRight))
  6.    c = Application.Lookup(9.9E+307, A.EntireColumn)
  7.    d = Application.Lookup(9.9E+307, A.EntireColumn, .Columns("A"))
  8.    ReDim Preserve Ar(s)
  9.    Ar(s) = Array(A.Value, CDate(d), c)
  10.    s = s + 1
  11. Next
  12. With ¤u§@ªí2
  13.    .UsedRange.ClearContents
  14.    .[A1].Resize(s, 3) = Application.Transpose(Application.Transpose(Ar))
  15. End With
  16. End With
  17. End Sub
½Æ»s¥N½X
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

¤j¤j¡AÁÂÁ¡A¥i¥H©M§A½u¤W½Ð¯q¨Ì¤U¶Ü

TOP

¦^´_ 4# idnoidno

°õ¦æµ²ªG¦p¤U2¹Ï
   

TOP

¦^´_ 4# idnoidno

§Ú¦A°õ¦æ¤@¦¸¡Aµ²ªG¬O§A­nªº·N«ä¡A¤£¹L§ÚÁÙ¬O­×§ï¤@¤U
  1. Sub ¥¨¶°1()
  2. n = 1
  3. For Each Rng In ¤u§@ªí1.Range("B1", ¤u§@ªí1.Cells(1, Columns.Count).End(xlToLeft).Address) '²Ä¤@¦C"°ÊºA"Ū¨ú°µ´`Àô
  4.     RngRow = ¤u§@ªí1.Columns(Rng.Column).Find("*", , , , , xlPrevious).Row '´M§ä§ïÄ檺³Ì«á¤@­ÓÀx¦s®æ
  5.     ¤u§@ªí2.Cells(n, 1) = Rng
  6.     ¤u§@ªí2.Cells(n, 2) = ¤u§@ªí1.Cells(RngRow, 1) '¤é´Á¼g¤J¤u§@ªí2
  7.     ¤u§@ªí2.Cells(n, 3) = ¤u§@ªí1.Cells(RngRow, Rng.Column) '³Ì«áªº¼Æ­È¼g¤J¤u§@ªí2
  8.     n = n + 1
  9. Next
  10. End Sub
½Æ»s¥N½X
¤G¡B§Úµ{§Ç¬O°µ°ÊºA´`Àô¡A¥H§A¤W¶ÇªºÀÉ®×¥h°µªº¡A¨Ì³o­ÓÀÉ®×¥u°µ¤F"¥Ò¤A¤þ"3¦¸´`Àô¡A©Ò¥H§A»¡ªº¤Ó¦hLoop¬O«ü3¦¸¤Ó¦h¶Ü¡H

TOP

        ÀR«ä¦Û¦b : µÊ®ð¼L¤Ú¤£¦n¡A¤ß¦a¦A¦n¤]¤£¯àºâ¬O¦n¤H¡C
ªð¦^¦Cªí ¤W¤@¥DÃD