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

[µo°Ý] ¦p¦ó³B²z¥ÎFIND®É¥X²{ªºERROR91?

[µo°Ý] ¦p¦ó³B²z¥ÎFIND®É¥X²{ªºERROR91?

Name Amount
A     11
A     12
A     13
B     13
B     11
B     14
D     18

²{¦b§Ú¦b¼g¤@­Ó¤pµ{¦¡¥h¾ã²z¸ê®Æ¡A¦Ó¹Lµ{¤¤§Ú»Ý­nª¾¹D¬Y¤@¶µ¸ê®Æ³Ì«á¥X²{ªº¦ì¸m¡A¨Ò¦p¡G
last = x.columns(1).Find(CELL_FIND(I), SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row

¦pªGCELL_FIND(I) ="B", last =6

find³o­Ó«Ü¦n¡A«Ü®e©ö§ä¨ì²Ä¤@¦¸¥X²{©M³Ì«á¥X²{ªº¦ì¸m¡C¦ý§Úµo²{¡A¦pªG·íCOLUMN A¨S¦³CELL_FIND¥]§tªº¸ê®Æ¡A¨Ò¦p¡G"C"¡A
¨t²Î´N·|¥X²{error 91, ¨S¦³³]©wª«¥óÅܼƩÎWITH°Ï°ìÅܼÆ

¥Ñ©ó§ÚµLªk¦b´M§ä«e´Nª¾¹D¨º¨ÇKEYWORD¬O¦b¥Ø¼Ð°Ï°ì¨S¦³¡A©Ò¥H§ÚµLªk¦^Á׳o­Ó°ÝÃD¡C½Ð°Ý¦U¦ì¡A¥i¥H¦p¦ó¸Ñ¨M©O¡H
©ÎªÌ¦³¨S¦³¥t¥~¤èªk¥h§ä¥X¸ê®Æªº²Ä¤@¦¸¥X²{©M³Ì«á¥X²{ªº¦ì¸m¡HÁÂÁÂ

¦^´_ 1# ¤p«L«È

Dim a as range
    set a= x.columns(1).Find(CELL_FIND(I), SearchOrder:=xlByRows, SearchDirection:=xlPrevious)
if not a is nothing then last = a.Row else msgbox "§ä¤£¨ì¸ê®Æ"
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

¸Õ¤Fª©¥Dªº¤èªk¡A¯uªº¥i¦æ¡AÁÂÁ§A¡I

TOP

¥»©«³Ì«á¥Ñ ¤p«L«È ©ó 2012-8-2 16:34 ½s¿è
¦^´_  ¤p«L«È

Dim a as range
    set a= x.columns(1).Find(CELL_FIND(I), SearchOrder:=xlByRows, S ...
Hsieh µoªí©ó 2012-8-2 11:53



Hsieh¤j¤j¡A§Ú¦³¤@­ÓºÃ°Ý¡A°²³]§Ú¦bA1:A10 ªº­È³£¬O¡u³¯¤j¤å¡v

¥ÎFIND ¨Ó§ä¥X²Ä¤@­Ó¥X²{³¯¤j¤åªº¦ì¸m¡G

Dim a As Range
    Set a = Columns(1).Find("³¯¤j¤å", SearchOrder:=xlByRows, SearchDirection:=xlFirst)

§Ú§Æ±æ a.row= 1¡A¦ýEXCEL¦^µ¹§Úªº¬O2¡A½Ð°Ý¬O¬°¤°»ò¡H¦³¤èªk­×¥¿¶Ü¡H
P.S. §Ú¤£·Qª½±µ´î1¡A¦]¬°³o¼Ë°µ·|¼vÅTµ{¦¡ªº¨ä¥L³¡¥÷¡AÁÂÁÂ

TOP

¦^´_ 4# ¤p«L«È
  1. Sub ex()
  2. Set a = Columns("A").Find("³¯¤j¤å", after:=[A65536], SearchOrder:=xlByRows, SearchDirection:=xlFirst)
  3. MsgBox a.Row
  4. Set a = Columns("A").Find("³¯¤j¤å", after:=[A65536], SearchOrder:=xlByRows, SearchDirection:=xlPrevious)
  5. MsgBox a.Row
  6. End Sub
½Æ»s¥N½X
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

¦^´_ 4# ¤p«L«È
  1. Sub Ex() '«ü©wªº¦ì¸m¥²¶·¬O½d³ò¤ºªº¦ì¸m
  2.     Dim A As Range, Rng As Range
  3.     Set Rng = [A1:A10]
  4.     Set A = Rng.Find("³¯¤j¤å")                                       '¹w³]: ±q½d³ò²Ä1­Ó¦ì¸m(¤£§t)¶}©l§ä
  5.     MsgBox A.Row
  6.     Set A = Rng.Find("³¯¤j¤å", After:=Rng(1).Cells(Rng.Rows.Count))  '«ü©w±q³Ì«áªº¦ì¸m§ä°_
  7.     MsgBox A.Row
  8.     Set A = Rng.Find("³¯¤j¤å", After:=Rng(5))                        '«ü©w±q½d³òªºCells(5)ªº¦ì¸m§ä°_
  9.     MsgBox A.Row
  10. End Sub
½Æ»s¥N½X

TOP

        ÀR«ä¦Û¦b : ¤@¥y·Å·xªº¸Ü¡A´N¹³©¹§O¤H¨­¤WÅx­»¤ô¡A¦Û¤v·|ªg¨ì¨â¤Tºw¡C
ªð¦^¦Cªí ¤W¤@¥DÃD