- ©«¤l
- 835
- ¥DÃD
- 6
- ºëµØ
- 0
- ¿n¤À
- 915
- ÂI¦W
- 0
- §@·~¨t²Î
- Win 10,7
- ³nÅ骩¥»
- 2019,2013,2003
- ¾\ŪÅv
- 50
- ©Ê§O
- ¨k
- µù¥U®É¶¡
- 2010-5-3
- ³Ì«áµn¿ý
- 2024-11-14
|
Àx¦s®æ¤º¦³¨ç¼Æ¡A¦ý·Qn¤â°Ê¿é¤J®É·|Åý즳¨ç¼Æ¤£¨£
ÁÙ¦³¥æ¤e¤ñ¹ïªº°ÝÃD
½Ð°Ýn«ç»ò§ï¤~¦n
§Æ±æ¥ÎVBA(¨ä ...
j88141 µoªí©ó 2014-4-4 15:21 
Module1 :- Public v11, v12, v21, v22
½Æ»s¥N½X Workbook :- Private Sub Workbook_Open()
- Dim vA
- Dim rSou As Range, rTar As Range
-
- Set v11 = CreateObject("Scripting.Dictionary")
- Set v12 = CreateObject("Scripting.Dictionary")
- Set v21 = CreateObject("Scripting.Dictionary")
- Set v22 = CreateObject("Scripting.Dictionary")
-
- Set rSou = Sheets("¤u§@ªí1").Range("A:A").SpecialCells(xlCellTypeConstants)
- For Each rTar In rSou
- If rTar <> "" And Left(rTar, 2) <> "¬P´Á" Then v11(CStr(rTar)) = 1
- Next
-
- Set rSou = Sheets("¤u§@ªí1").Range("C:C").SpecialCells(xlCellTypeConstants)
- For Each rTar In rSou
- If rTar <> "" And Left(rTar, 2) <> "¬P´Á" Then v12(CStr(rTar)) = 1
- Next
- Set rSou = Sheets("¤u§@ªí2").Range("A:A").SpecialCells(xlCellTypeConstants)
- For Each rTar In rSou
- If rTar <> "¥N¸¹" Then
- v21(CStr(rTar)) = rTar.Offset(, 1)
- v22(CStr(rTar)) = rTar.Offset(, 2)
- End If
- Next
- End Sub
½Æ»s¥N½X ¤u§@ªí3 :- Private Sub Worksheet_Change(ByVal Target As Range)
- Dim bNFind As Boolean
-
- With Target
- If .Count = 1 Then
- If .Row = 1 Then ' A1 ©Î B1
- bNFind = True
- Select Case .Column
-
- Case 1
- If v11.exists(CStr(v22(CStr(Target)))) Then
- .Offset(1) = v21(CStr(Target))
- .Offset(2) = v22(CStr(Target))
- bNFind = False
- End If
-
- Case 2
- If v12.exists(CStr(v22(CStr(Target)))) Then
- .Offset(1) = v21(CStr(Target))
- .Offset(2) = v22(CStr(Target))
- bNFind = False
- End If
-
- Case Else
- bNFind = False
-
- End Select
-
- If bNFind Then
- MsgBox v22(CStr(Target)) & " ¨S¦³±Æ¯Z"
- .Resize(3).ClearContents
- .Select
- End If
- End If
- End If
- End With
- End Sub
½Æ»s¥N½X
¬¡¶Ã¯1-a.zip (19.91 KB)
|
|