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

[µo°Ý] ÅÞ¿è±ø¥ó§PÂ_½Ð¯q

[µo°Ý] ÅÞ¿è±ø¥ó§PÂ_½Ð¯q

¥»©«³Ì«á¥Ñ li_hsien ©ó 2015-2-9 18:50 ½s¿è

¦³­ÓÅÞ¿è§PÂ_°ÝÃD½Ð±Ð¦U¦ì¤j¤j

¥D­nÅÞ¿è -> ¦pªGA2¸òCÄæ¤ñ¹ï¡A¦³¤ñ¨ìªº¸Ü«hB2­È=D2

§P§O±ø¥ó²Ó¤À:
1. ¦pªGA2¸òCÄævlookup¤ñ¹ïªº¨ì
2. ¦pªG¤ñ¨ìªº­È(D2)¤£¬°ªÅ­È
­Y¤W­z±ø¥ó¦¨¥ß«h±ND2­È¶ñ¤JB2
  1.      
  2. If IsError(Application.VLookup(Range("A2") , Range("C:D") , 2 , 0)) = False And Application.VLookup(Range("A2") , Range("C:D") , 2 , 0) <> "" Then
  3.         
  4.         Range("B2") = Application.VLookup(Range("A2") , Range("C:D") , 2 , 0)
  5.      
  6. End If
½Æ»s¥N½X
²{¦b¥O¤p§ÌºÃ´bªºÂI¬O

¬°¤°»ò§ÚA2ªº­È½T¹ê¤£¦s¦b©óCÄ椤

¦ýB2ÁÙ¬O·|³Q¶ñ¤J­È(Åã¥Ü#NA)
  1. IsError(Application.VLookup(Range("A2") , Range("C:D") , 2 , 0))
½Æ»s¥N½X
¤W¤è³o¬q ¦pªGA2¤£¦s¦b©óCÄ椤¤£¬OÀ³¸Óµ¥©óTrue¶Ü???
©Ò¥H§Ú±ø¥ó¬Oµ¥©óFalseÀ³¸Ó¤£·|©¹¤U°õ¦æ§a???


¤£ª¾¤p§Ì¬O­þÃä»~¸Ñ  ·Ð½Ð¦U¦ì¸Ñ´b

ÁÂÁ¡I¡I¡I
¥Î¥\¨ì¥@¬É¥½¤é¨º¤@¤Ñ¡ã¡ã¡ã

¦^´_ 5# li_hsien
¹ï§Ú¨Ó»¡³o¼Ë´N¬OÀݥΤF¡A¦]¬°§A¬O¬°¤FÁקK¤£ª¾¹D¦ó®É¦ó³B·|¥X²{ªº¿ù»~°T®§¡A¦Ó¥u¦b¤@¶}©lªº¦a¤è¥[ On Error Resume Next ¡A³o¼Ë¬O¤£¹ïªº¡C
On Error Resume Next À³¸Ó¥Î¦b§Aª¾¹D·|µo¥Í°õ¦æ¶¥¬q¿ù»~ªº¦a¤è(¸Ó¦æµ{¦¡½X)¡A¦Ó¥B§Aª¾¹D¿ù»~ªº­ì¦]¨Ã¥B§A§PÂ_¥i¥H©¿²¤³o¿ù»~¡AµM«á¦b¸Ó¦æ«e­±¥[ On Error Resume Next¡A¸Ó¦æ«á­±¥[ On Error Goto 0¡A³o¼Ë¤~¬O¥¿½Tªº¥Îªk¡C
ªí¹F¤£²M¡BÃD·N¤£©ú½T¡B¨SªþÀɮ׮榡¡B¨S¦³°Q½×°ÝÃDªººA«×~~~~~~¥H¤W·R²ö¯à§U¡C

TOP

¦^´_ 4# stillfish00

ÁÂÁÂstillfish00¨ó§U

¨ä¹ê³]©wOn Error Resume Next

¥D­n¬O¦]¬°±`±`·|µ¹¨Ï¥ÎªÌ¨Ï¥Î

ºÉ¥i¯à¤£­nÅý¿ù»~°T®§¸õ¥X¨Ó

¦ý­n¥HMsgÅã¥Ü¦n¹³¨S¦³¤ñ¸û¾A·íªº¦r²´

©Ò¥H´N¥[¤W¥h¤F

¦ý¯ÊÂI´N¬Oµ{¦¡½X­Y¦³»~ ±`·|¤@®É§ì¤£¥X¨Ó@@
¥Î¥\¨ì¥@¬É¥½¤é¨º¤@¤Ñ¡ã¡ã¡ã

TOP

¥»©«³Ì«á¥Ñ stillfish00 ©ó 2015-2-11 11:16 ½s¿è

¦^´_ 3# li_hsien
¨S¿ù°Ú¡A³oºØ±ø¥ó´N¬O­n¤À¶}¼g
µM«á§A¥i¥H§â vlookup ¬dªíªº­È´£¥X¨Ó¡A¤£µM§A³o¼Ë­n¬d3¦¸
  1. Sub Test33()
  2.   Dim value As Variant  
  3.   value = Application.VLookup(Range("A2"), Range("C:D"), 2, 0)
  4.   If IsError(value) Then
  5.     MsgBox Range("A2") & " is not found": Exit Sub
  6.   ElseIf value <> "" Then
  7.     Range("B2").value = value
  8.   End If
  9. End Sub
½Æ»s¥N½X
­«ÂI¬O: ÀݥΠOn Error Resume Next ¬O¤j§Ò
ªí¹F¤£²M¡BÃD·N¤£©ú½T¡B¨SªþÀɮ׮榡¡B¨S¦³°Q½×°ÝÃDªººA«×~~~~~~¥H¤W·R²ö¯à§U¡C

TOP

¦^´_ 2# stillfish00

·PÁÂstillfish´£ÂI¡I¡I¡I

¯uªº¬OOn Error Resume Nextªº¼vÅT

«á¨Ó§Úµo²{¤U¬q³o¦æ
  1. Application.VLookup(Range("A1"), Range("C:D"), 2, 0) <> ""
½Æ»s¥N½X
¦]¬°¤ñ¹ï¤£¨ì©Ò¥H¥X¿ù¤F

¦ý§Ú¤U¤FOn Error Resume Next©Ò¥H´N©¹¤U°õ¦æ¤F

¾É­P­Èµ¹¤F#NA


«á¨Ó­×¥¿§@ªkÅܦ¨¬O±N¨â­Ó±ø¥ó¤À¶}
  1. If IsError(Application.VLookup(Range("A1"), Range("C:D"), 2, 0)) = False Then

  2.     If Application.VLookup(Range("A1"), Range("C:D"), 2, 0) <> "" Then   
  3.        Range("B1") = Application.VLookup(Range("A2"), Range("C:D"), 2, 0)
  4.     End If
  5.         
  6. End If
½Æ»s¥N½X
¦ý¦n¹³¤£¬O«ÜÁo©úªº§@ªk@@
¥Î¥\¨ì¥@¬É¥½¤é¨º¤@¤Ñ¡ã¡ã¡ã

TOP

¦^´_ 1# li_hsien
ªþÀɬݬݧa, §Úª½±µrun§A³o¼gªk·|¦³°õ¦æ¶¥¬q¿ù»~¡C

¸Ó¤£·|§A«e­±¤U¤F On Error Resume Next «ü¥O§a...
ªí¹F¤£²M¡BÃD·N¤£©ú½T¡B¨SªþÀɮ׮榡¡B¨S¦³°Q½×°ÝÃDªººA«×~~~~~~¥H¤W·R²ö¯à§U¡C

TOP

        ÀR«ä¦Û¦b : ¬Ý§O¤H¤£¶¶²´¡A¬O¦Û¤v­×¾i¤£°÷¡C
ªð¦^¦Cªí ¤W¤@¥DÃD