Board logo

¼ÐÃD: [µo°Ý] ½Ð°ÝVBA ªºµ{¦¡¦³¨S¦³¥i¥H¿ë»{¬Y­ÓÀx¦s®æ¤ºªº¦r¤¸¦³µL¥]§t¬Y´X­Ó¦r¦ê¡H [¥´¦L¥»­¶]

§@ªÌ: 198188    ®É¶¡: 2013-3-1 00:48     ¼ÐÃD: ½Ð°ÝVBA ªºµ{¦¡¦³¨S¦³¥i¥H¿ë»{¬Y­ÓÀx¦s®æ¤ºªº¦r¤¸¦³µL¥]§t¬Y´X­Ó¦r¦ê¡H

½Ð°ÝVBA ªºµ{¦¡¦³¨S¦³¥i¥H¿ë»{¬Y­ÓÀx¦s®æ¤ºªº¦r¤¸¦³µL¥]§t¬Y´X­Ó¦r¦ê¡H
¨Ò¦p
¥t¥~µL½×¬O¤j¼g©Î¤p¼g³£¿ë»{¨ì
in   A1  A3  A4 ¥]§t in
A1   window   
A2  office
A3  tina
A4  WINNIE   

¥t¥~¥i§_§ä´M¦r¦êªº¦ì¸m
¨Ò¦p
in   
A1   window                       3
A2  office   
A3  tina                                2
A4  WINNIE                       2
§@ªÌ: kimbal    ®É¶¡: 2013-3-1 00:54

¥»©«³Ì«á¥Ñ kimbal ©ó 2013-3-1 01:07 ½s¿è
½Ð°ÝVBA ªºµ{¦¡¦³¨S¦³¥i¥H¿ë»{¬Y­ÓÀx¦s®æ¤ºªº¦r¤¸¦³µL¥]§t¬Y´X­Ó¦r¦ê¡H
¨Ò¦p
¥t¥~µL½×¬O¤j¼g©Î¤p¼g³£¿ë»{ ...
198188 µoªí©ó 2013-3-1 00:48


¥ÎEXCELªºSEARCH¤½¦¡§Y¥i
    =IF(ISERROR(SEARCH("IN",UPPER(A1))),"",SEARCH("IN",UPPER(A1)))
[attach]14275[/attach]

VBA ªº¸Ü
[attach]14277[/attach]
  1. Public Function csearch(find_text, rng_within)
  2.     Dim result
  3.     result = InStr(1, UCase(rng_within.Value), UCase(find_text))
  4.     csearch = IIf(result = 0, "", result)
  5. End Function
½Æ»s¥N½X

§@ªÌ: 198188    ®É¶¡: 2013-3-1 01:00

¦^´_ 2# kimbal


    ·PÁ¡A¦ý¥Î¤@¯ëexcel§Úª¾¹D¡A§Ú·Qª¾¹Dvba¦³µL³o­Ó¥\¯à¡H
§@ªÌ: kimbal    ®É¶¡: 2013-3-1 01:07

¦^´_  kimbal


    ·PÁ¡A¦ý¥Î¤@¯ëexcel§Úª¾¹D¡A§Ú·Qª¾¹Dvba¦³µL³o­Ó¥\¯à¡H
198188 µoªí©ó 2013-3-1 01:00



    ½Ð¬Ý¤W­±½s¿è
§@ªÌ: 198188    ®É¶¡: 2013-3-1 01:26

¦^´_ 4# kimbal

·PÁÂ
    csearch = IIf(result = 0, "", result)
½Ð°Ý¦pªG¥u¬OÀˬd¦³¨S¦³¬O§_§ï¦¨csearch = IIf(result = 0, "¨S¦³", ¡§¦³¡¨)

¥t¥~½Ð°Ý
DO
UNTIL
¥i§_¦P®É¦³¨â­ÓUNTILªº±ø¥ó
¨Ò¦p¡G
DO

UNTIL i>=1 or l = 0
UNTIL i>=1 and l = 0
§@ªÌ: 198188    ®É¶¡: 2013-3-1 01:33

¦^´_  kimbal

·PÁÂ
    csearch = IIf(result = 0, "", result)
½Ð°Ý¦pªG¥u¬OÀˬd¦³¨S¦³¬O§_§ï¦¨csea ...
198188 µoªí©ó 2013-3-1 01:26



    ³o­Óµ{¦¡¬O§_»Ý­n¦bCÄæ³B¼g csearch("in"a1,)?
¦pªG¦bVBA¤ºª`©ú SEARCH "IN"¥i¥H¶Ü¡H¥t¥~­^¤å¤j¼g©M¤p¼g³£¥i¥H¿ë»{¨ì¶Ü¡H©ÎªÌ¦p¦ó«ü©w¿ë»{¤j¼g©Î¤p¼g¡H
§@ªÌ: kimbal    ®É¶¡: 2013-3-1 13:39

¦^´_ 6# 198188


    ¦^´_ 4# kimbal


>    csearch = IIf(result = 0, "", result)
> ½Ð°Ý¦pªG¥u¬OÀˬd¦³¨S¦³¬O§_§ï¦¨csearch = IIf(result = 0, "¨S¦³", ¡§¦³¡¨)

¹ï°Ú,´N¬O³o¼Ë.


>¥t¥~½Ð°Ý
>DO
>UNTIL
>¥i§_¦P®É¦³¨â­ÓUNTILªº±ø¥ó
>¨Ò¦p¡G
>DO
>UNTIL i>=1 or l = 0
>UNTIL i>=1 and l = 0

¥i¥Hªº,³o¼Ë´N¥i
    Do
        ...
    Loop Until i> = 5 and l = 0
///
    Do
        ...
    Loop Until i> = 5 Or l = 0



>¦pªG¦bVBA¤ºª`©ú SEARCH "IN"¥i¥H¶Ü¡H¥t¥~­^¤å¤j¼g©M¤p¼g³£¥i¥H¿ë»{¨ì¶Ü¡H©ÎªÌ¦p¦ó«ü©w¿ë»{¤j¼g©Î¤p¼g¡H

²{¦b¬O¤£½×¤j¼g¤p¼g³£¥i¥H¿ë»{¨ìªº,
¦]¬°¥Î¤Fucase§â¨â­Ó¿é¤J³£¥ýÂন¤j¼g,µM«á¤~°µ¤ñ¸û
result = InStr(1, UCase(rng_within.Value), UCase(find_text))
¨Ò¦p:
result  = Instr(1, ucase("abc"), ucase("B"))
­pºâ®É·|Åܬ°
result  = Instr(1, "ABC", "B")
result = 2


®³¨«ucase´Nªº¸Ü´N­n¤j¤p¼g¥þ¹ï¤~¥i¥H§ä¨ì¦ì¸m
result = InStr(1, rng_within.Value, find_text)
¨Ò¦p:
result  = Instr(1, "abc", "B")
result = 0

§â"B"§ï¦¨"b"´N¥i¥H±o¥X2
result  = Instr(1, "abc", "b")
result = 2
§@ªÌ: mark15jill    ®É¶¡: 2013-3-1 15:28

¥i¥H°Ñ¦Ò¥H¤U­ì©l½X
¬õ¦r§Y¬°»Ý·j´M±o¦r¦ê
Sub A()
                     ¤u§@ªí3.Cells(1, 16) = "·j´M¥Ø¼Ð·½"
                     ¤u§@ªí3.Cells(1, 17) = "§PÂ_¬O§_§ä¨ì"
                     ¤u§@ªí3.Cells(1, 18) = "ÃöÁä¦r¦ì¸m"
                     ¤u§@ªí3.Cells(1, 19) = "¥N½X"


        For i = 2 To ActiveSheet.Range("b2").CurrentRegion.Rows.Count
                If (InStr(1, ¤u§@ªí3.Cells(i, 2), "¤º") >= 1) Then
                     ¤u§@ªí3.Cells(i, 16) = ¤u§@ªí3.Cells(i, 2) '·j´M¥Ø¼Ð·½
                     ¤u§@ªí3.Cells(i, 17) = "find" '§PÂ_¬O§_§ä¨ì
                     ¤u§@ªí3.Cells(i, 18) = InStr(¤u§@ªí3.Cells(i, 2), "¤º") 'ÃöÁä¦r¦ì¸m
                     ¤u§@ªí3.Cells(i, 19) = "3"  '¥N½X
                     s = s + 1
                End If
        Next
              ' ¤u§@ªí3.Cells(i, 17) = "find"
End Sub
§@ªÌ: 198188    ®É¶¡: 2013-3-8 15:56

  1. Sub Load_State_Detail()
  2. Dim FRng As Range
  3. Dim A As Range, Rng As Range
  4. Dim i As Integer
  5. Dim LastRec As Integer
  6. Dim l As Integer
  7. Dim k As Integer
  8. Dim j As Integer


  9. j = 2
  10. LastRec = Sheets("state").Range("A1").CurrentRegion.Rows.Count
  11. fs = "W:\Payment Daily Report\DOCS RECEIVED N RELEASED RECORD.xlsx"
  12. Set Wb = Workbooks.Open(fs)
  13. With ThisWorkbook.Worksheets("State")
  14. k = Wb.Sheets("¦¬¥ó°O¿ý").Range("A1").CurrentRegion.Rows.Count
  15. For l = 2 To LastRec

  16. Do
  17. If Worksheets("State").Range("A" & l).Value = Wb.Sheets("¦¬¥ó°O¿ý").Range("A" & j).Value Then
  18. Worksheets("State").Range("J" & l).Value = Wb.Sheets("¦¬¥ó°O¿ý").Range("h" & j)
  19. If (InStr(1, Worksheets("State").Cells(l, 10), "OBL") >= 1) Then Worksheets("State").Range("J" & l).Value = Wb.Sheets("¦¬¥ó°O¿ý").Range("h" & j) Else Worksheets("State").Range("J" & l).Value = ""
  20. End If
  21. j = j + 1
  22. Loop Until j = k Or (InStr(1, Worksheets("State").Cells(l, 10), "OBL") >= 1)
  23. Next
  24. End With
  25. End Sub
½Æ»s¥N½X
¦^´_ 7# kimbal

[attach]14315[/attach][attach]14316[/attach]
­Óµ{¦¡If Worksheets("State").Range("A" & l).Value = Wb.Sheets("¦¬¥ó°O¿ý").Range("A" & j).Value Then ¥X²{RUN TIME ERROR "9" SUBSCRIP OUT OF RANG?
§Ú³o­Óµ{¦¡ªº§@¥Î¬O
¦btest excelùتºstate sheet AÄ檺­q³æ¸¹¦pªG¦bDOCS RECEIVED N RELEASED RECORDªí¤º¦³³o­Ó­q³æ¸¹¡A¦Ó¥B¦bHÄæùتº¦r¤¸§t¦³"OBL"¡A ¨º»ò¦btest excelùتºstate sheetªºJÄæ´NÅã¥ÜDOCS RECEIVED N RELEASED RECORDªí¤ºHÄ檺¦r¡A§_«h´NªÅ®æ
§@ªÌ: 198188    ®É¶¡: 2013-3-8 15:58

¦^´_ 8# mark15jill

½ÐÀ°§Ú¬Ý¬Ý¤W­±ªº°ÝÃD¡AÁÂÁÂ
§@ªÌ: mark15jill    ®É¶¡: 2013-3-8 16:41

¦^´_ 10# 198188


    ¤j¤j±z¼gªº¦nªø....
    ±N¨â­Ó¬¡­¶Ã¯¦X¨Ö¦¨¤@­ÓÀɮקPÂ_.. (¼gªk©M ¨â­Ó¬¡­¶Ã¯¤À¶}ªº¼gªk®t¤£¦h)
   ®Ú¾Ú±z©Òµo°Ýªº°ÝÃD¡A¥H²©öªºµ{¦¡§PÂ_..

st1 = ¤u§@ªí1.Range("a2").CurrentRegion.Rows.Count
st2 = ¤u§@ªí2.Range("d2").CurrentRegion.Rows.Count

For k1 = 2 To st1
    For k2 = 2 To 233
        If ¤u§@ªí2.Cells(k2, "D") = ¤u§@ªí1.Cells(k1, "A") And (InStr(1, ¤u§@ªí2.Cells(k2, "H"), "OBL") >= 1) Then
         '¤u§@ªí2.Cells(k2, "c") = "¹ïÀ³¨ì" & ¤u§@ªí1.Cells(k1, "A")'¦¹¦æ¬° ¦b¤u§@ªí2 CÄæ¼Ðµù DÄæ¦ì¬O§_¦³²Å¦X ¤u§@ªí1  AÄæ¦ì
         ¤u§@ªí1.Cells(k1, "J") = ¤u§@ªí2.Cells(k2, "H")
        End If
    Next
Next
§@ªÌ: 198188    ®É¶¡: 2013-3-8 22:25

¦^´_ 11# mark15jill
  1. Sub State_Detail()
  2. Dim FRng As Range
  3. Dim a As Range, Rng As Range
  4. Dim i As Integer
  5. Dim LastRec As Integer
  6. Dim z As Integer
  7. Dim y As Integer
  8. Dim x As Integer
  9. Dim w As Integer

  10. z = Sheets("state").Range("a2").CurrentRegion.Rows.Count
  11. fs = "C:\Documents and Settings\USER\®à­±\DOCS RECEIVED N RELEASED RECORD.xlsx"
  12. Set WB = Workbooks.Open(fs)

  13. With ThisWorkbook.Worksheets("State")

  14. x = 2
  15. For w = 2 To z
  16.     Do
  17.         If WB.Sheets("¦¬¥ó°O¿ý").Cells(x, "D") = Sheets("state").Cells(w, "A") And (InStr(1, WB.Sheets("¦¬¥ó°O¿ý").Cells(x, "H"), "OBL") >= 1) Then
  18.                  Sheets("state").Cells(w, "J") = WB.Sheets("¦¬¥ó°O¿ý").Cells(x, "H")
  19.         End If
  20.         x = x + 1
  21.    Loop Until x = WB.Sheets("¦¬¥ó°O¿ý").Row.Count.End(xlUp)
  22. Next

  23. End With
  24. WB.Close 0
  25. End Sub
½Æ»s¥N½X
¥X²{°õ¦æ¶¥¬q¿ù»~9 °}¦C¯Á¤Þ¶W¥X½d³ò
§@ªÌ: Hsieh    ®É¶¡: 2013-3-8 23:14

¦^´_ 12# 198188
·|¥X²{¶W¥X°}¦C¯Á¤Þ¿ù»~¬O¦]¬°§A¦b¶}±Ò¨Ó·½ÀÉ¥H«á¡A¤@¯ë¼Ò²Õ¤ºµ{¦¡½X­Y¨S«ü©w¬¡­¶Ã¯¡A«h·|¥H·í«e§@¥Î¤¤ªº¬¡­¶Ã¯§@¬°¸Ó¬¡­¶Ã¯
³q±`§Ú·|³o»ò°µ¡A¤ñ¸û®e©ö§ä¥X¿ù»~ÂI
  1. Sub ex()
  2. Dim Sh As Worksheet, Rng As Range
  3. fd = ThisWorkbook.Path & "\"  '¸ê®Æ¨Ó·½¥Ø¿ý
  4. fs = "DOCS RECEIVED N RELEASED RECORD.xlsx" '¸ê®Æ¨Ó·½ÀÉ®×(§t°ÆÀɦW)
  5. With Workbooks.Open(fd & fs)
  6.   Set Sh = .Sheets("¦¬¥ó°O¿ý")
  7.       With ThisWorkbook.Sheets("State")
  8.          For Each A In .Range(.[A2], .Cells(.Rows.Count, 1).End(xlUp))
  9.             Set Rng = Sh.Columns("D").Find(A, lookat:=xlWhole)
  10.             If Not Rng Is Nothing Then
  11.                If InStr(Rng.Offset(, 4), "OBL") > 0 Then _
  12.                A.Offset(, 9) = Rng.Offset(, 4).Value Else A.Offset(, 9) = ""
  13.             End If
  14.          Next
  15.       End With
  16.     .Close
  17. End With
  18. End Sub
½Æ»s¥N½X

§@ªÌ: 198188    ®É¶¡: 2013-3-9 09:38

¦^´_ 13# Hsieh


    ¦³­Ó°ÝÃD¡A¦]¬°§ÚªºDATA BASEùتº­q³æ¸¹·|­«½Æ´X¦¸¡A Set Rng = Sh.Columns("D").Find(a, lookat:=xlWhole) ³o¥y¥u¬O·|§ä¤@¦¸
¨Ò¦p¡G
200000     PLANT INV
200000     OHC
200000     OBL
200000     CO
200000     ¿ðµý«H

211111     OBL
211111     OHC
211111     CO

222222     OHC
222222     CO
222222     OBL
®ÄªG´NµLªk¥X²{
¦]¬°§Ú¬O·Q¥u­n­q³æ¸¹¬Û¦P¡A¦Ó¥B³o¨Ç­q³æ¸¹¥u­n¦³¤@¦C¦³OBL¤T­Ó¦r¡A´N¥X²{OBL§_«hªÅ®æ
§@ªÌ: GBKEE    ®É¶¡: 2013-3-9 11:23

¥»©«³Ì«á¥Ñ GBKEE ©ó 2013-3-9 12:52 ½s¿è

¦^´_ 14# 198188
Set Rng = Sh.Columns("D").Find(a, lookat:=xlWhole) ³o¥y¥u¬O·|§ä¤@¦¸
¦p¤U¥i´M§ä¥þ³¡
  1. Option Explicit
  2. Sub Ex()
  3.     Dim A As String, Rng As Range, Sh As Worksheet, Address_First As String
  4.     Dim M As String
  5.     Set Sh = ActiveSheet
  6.     A = "OBL"                                          '´M§äªº¦r¦ê
  7.     Set Rng = Sh.Columns("D").Find(A, lookat:=xlWhole) '²Ä¤@­Ó
  8.     If Not Rng Is Nothing Then
  9.         Address_First = Rng.Address                    '¼g¤U²Ä¤@­Ó¦ì§}
  10.         Do
  11.             M = IIf(M <> "", M & ",", "") & Rng.Address
  12.             Set Rng = Sh.Columns("D").FindNext(Rng)   'Ä~Äò´M§ä¤U¤@­Ó
  13.         Loop Until Address_First = Rng.Address        '¦^¨ì²Ä¤@­Ó¦ì§}
  14.         MsgBox M
  15.      Else
  16.         MsgBox "§ä¤£¨ì"
  17.     End If
  18. End Sub
  19. Sub Ex_1()
  20.     Dim A As String, Rng As Range, Sh As Worksheet, Address_First
  21.     Set Sh = ActiveSheet
  22.     A = "OBL"                                           '´M§äªº¦r¦ê
  23.     Set Rng = Sh.Columns("D").Find(A, lookat:=xlWhole)  '²Ä¤@­Ó
  24.     If Not Rng Is Nothing Then
  25.         With Sh.Columns("D")
  26.             .Replace A, "=ABC", xlWhole                 '­×§ï"´M§äªº¦r¦ê" = ¨S©w¸qªº¦WºÙ
  27.             Set Rng = .SpecialCells(xlCellTypeFormulas, xlErrors) 'Àx¦s®æ¦³¿ù»~­Èªº¯S©w½d³ò
  28.             Rng.Value = A                                '¨S©w¸qªº¦WºÙ §ï¦^ "´M§äªº¦r¦ê"
  29.             MsgBox Rng.Address
  30.         End With
  31.     Else
  32.         MsgBox "§ä¤£¨ì"
  33.     End If
  34. End Sub
½Æ»s¥N½X
¦]¬°§Ú¬O·Q¥u­n­q³æ¸¹¬Û¦P¡A¦Ó¥B³o¨Ç­q³æ¸¹¥u­n¦³¤@¦C¦³OBL¤T­Ó¦r¡A´N¥X²{OBL§_«hªÅ®æ
¤£¤F¸Ñ§AÀɮפº®e µLªk¦^µª
§@ªÌ: 198188    ®É¶¡: 2013-3-9 11:44

¦^´_ 15# GBKEE


§Ú·Q­nªº®ÄªG¬O®Ú¾ÚTest.xlsmªºState Sheet ªºAÄ檺­q³æ¸¹¡A¨Ó´M§äDOCS RECEIVED N RELEASED RECORD.xlsx ¦¬³æ°O¿ýSHEET¤ºDÄæ¬O§_¦³¬Û¦Pªº­q³æ¸¹©MHÄ檺¦r¤¸¤º¥]§t"OBL"¤T­Ó¦r¡]¤j¤p¼g³£¨S¦³°ÝÃD¥i¥HŪ¨ì¡^¡A¦pªG¦³¡A¦bTest.xlsmªºState Sheet ªº¬ÛÀ³ªº­q³æ¸¹JÄæÅã¥ÜDOCS RECEIVED N RELEASED RECORD.xlsx ¦¬³æ°O¿ýSHEET¤ºHÄ檺¸ê®Æ¡C¦pªG¨S¦³´NªÅ®æ¡C
«e­±¦³ªþ¥ó
Test.xlsm
State sheet
AÄæ                JÄæ
20000          OBL-3
20001
20002
20003          OBL
20004          OBL

W:\Payment Daily Report\DOCS RECEIVED N RELEASED RECORD.xlsx"
¦¬³æ°O¿ýSHEET
DÄæ                          HÄæ
20000                     ¿ðµý«H
20000                     OBL-3
20003                     OHC(BODY-1,OIE-1,ACCEPTED BSE-1),CO
20000                     OHC(BODY-1,HPAI-1)
20004                     OHC(BODY-1,OIE-1,ACCEPTED BSE-1,AD-1,CL-1)
20005                     OHC(BODY-1)
20003                     OBL
20003                     INV
20005                     INV
20005                     OBL
20004                     OBL
§@ªÌ: GBKEE    ®É¶¡: 2013-3-9 13:15

¦^´_ 16# 198188
  1. Option Explicit
  2. Sub Ex()
  3.     Dim R As Range, Rng As Range, E As Range
  4.     With Sheet1                         '*** ¶·§ï¬°: Test.xlsmªºState Sheet
  5.         Set R = .Cells(1, "a")          'A1¶}©l
  6.         Do Until R = ""                 'Â÷¶}°j°éªº±ø¥ó:  AÄ檺 Àx¦s®æ=""
  7.             With Sheet2                 '*** ¶·§ï¬°: W:\Payment Daily Report\DOCS RECEIVED N RELEASED RECORD.xlsx"
  8.                 Set Rng = .Columns("D").Find(R, lookat:=xlWhole)
  9.                  If Not Rng Is Nothing Then
  10.                     With .Columns("D")
  11.                         .Replace R, "=ABC", xlWhole                 '­×§ï"´M§äªº¦r¦ê" = ¨S©w¸qªº¦WºÙ
  12.                         Set Rng = .SpecialCells(xlCellTypeFormulas, xlErrors) 'Àx¦s®æ¦³¿ù»~­Èªº¯S©w½d³ò
  13.                         Rng.Value = R                               '¨S©w¸qªº¦WºÙ §ï¦^ "´M§äªº¦r¦ê"
  14.                         For Each E In Rng.Offset(0, 4)              'DÄæ¦ì²¾4Äæ=HÄæ
  15.                             If InStr(UCase(E), "OBL") Then          'HÄ檺¦r¤¸¤º¥]§t"OBL"¤T­Ó¦r
  16.                                                                     'UCase(E) Âà´«¬°¤j¼g
  17.                                 R.Offset(0, 9) = E.Value            'R.Offset(0, 9)-> AÄæ¦ì²¾¨ì JÄæ
  18.                                 'Test.xlsmªºState Sheet->JÄæ=DOCS RECEIVED N RELEASED RECORD.xlsx"->HÄ檺¦r¤¸
  19.                                 Exit For    '¦³§ä¨ì "OBL" Â÷¶}°j°é                          '
  20.                             End If
  21.                        Next
  22.                     End With                '.Columns("D")
  23.                 End If
  24.             End With                        'Sheet2
  25.             Set R = R.Offset(1)             '¤U²¾¨ì A2
  26.         Loop
  27.     End With                                'Sheet1
  28. End Sub
½Æ»s¥N½X

§@ªÌ: Hsieh    ®É¶¡: 2013-3-9 21:46

¦^´_ 14# 198188
  1. Sub ex()
  2. Dim Sh As Worksheet, Rng As Range, C As Range, Ar()
  3. fd = ThisWorkbook.Path & "\"  '¸ê®Æ¨Ó·½¥Ø¿ý
  4. fs = "DOCS RECEIVED N RELEASED RECORD.xlsx" '¸ê®Æ¨Ó·½ÀÉ®×(§t°ÆÀɦW)
  5. With Workbooks.Open(fd & fs)
  6.   Set Sh = .Sheets("¦¬¥ó°O¿ý")
  7.       With ThisWorkbook.Sheets("State")
  8.          For Each A In .Range(.[A2], .Cells(.Rows.Count, 1).End(xlUp))
  9.             Set Rng = Sh.Columns("D").Find(A, lookat:=xlWhole)
  10.             If Not Rng Is Nothing Then
  11.                For Each C In Sh.Range(Rng, Sh.Cells(Sh.Rows.Count, 4).End(xlUp))
  12.                   If C = A And InStr(UCase(C.Offset(, 4)), "OBL") > 0 Then
  13.                      ReDim Preserve Ar(s)
  14.                      Ar(s) = C.Offset(, 4)
  15.                      s = s + 1
  16.                   End If
  17.                 Next
  18.             If s > 0 Then A.Offset(, 9) = Join(Ar, "¡B"): Erase Ar: s = 0 Else A.Offset(, 9) = ""
  19.             End If
  20.          Next
  21.       End With
  22.     .Close
  23. End With
  24. End Sub
½Æ»s¥N½X

§@ªÌ: 198188    ®É¶¡: 2013-3-9 22:54

¦^´_ 18# Hsieh

¥i¥H¤F¡A·PÁ¤j¤j

fd = ThisWorkbook.Path & "\"  '¸ê®Æ¨Ó·½¥Ø¿ý
fs = "DOCS RECEIVED N RELEASED RECORD.xlsx" '¸ê®Æ¨Ó·½ÀÉ®×(§t°ÆÀɦW)
¥t¥~½Ð°Ý¤W­±¨â¥y
¦pªG§Ú¼g³o¥y´À¥N¤W­±¨â¥yfs = "W:\PIHK\DOCS RECEIVED N RELEASED RECORD.xlsx"
©ÎªÌ
fd = W:\PIHK\
fs = "DOCS RECEIVED N RELEASED RECORD.xlsx" '¸ê®Æ¨Ó·½ÀÉ®×(§t°ÆÀɦW)
³o¼Ë¹ï¶Ü¡H

Join(Ar, "¡B"): Erase ³o¥y¬O¤°»ò·N«ä¡H

¥t¥~½Ð°Ý¦pªG§Ú¥»¨Ó¦bstateªíªºJÄæ¤w¸g¦³¸ê®Æ¡A·|¦]À³¹F¨ì±ø¥ó¦Ó¨ú´À¸ê®Æ¡A¦ý¦pªG­n¸ÓÀx¦s®æ¬OªÅ®æ¤~¨ú´À

If s > 0 and trim(a.Offset(,9) )=¡§¡¨Then a.Offset(, 9) = Join(Ar, "¡B"): Erase Ar: s = 0 Else a.Offset(, 9) = "" ³o¼Ë¼g¹ï¶Ü¡H
§@ªÌ: 198188    ®É¶¡: 2013-3-9 23:00

¦^´_ 17# GBKEE


With Sheet1                        (³o¥y¬O§_§ïWith State sheet?)
With Sheet2                 (³o¥y¬O§_§ïWith W:\Payment Daily Report\DOCS RECEIVED N RELEASED RECORD.xlsx ¡H¡^¦ý¬O¦n¹³¤£¹ï¡H¡H
§@ªÌ: Hsieh    ®É¶¡: 2013-3-9 23:04

¦^´_ 19# 198188

¦pªG§Ú¼g³o¥y´À¥N¤W­±¨â¥yfs = "W:\PIHK\DOCS RECEIVED N RELEASED RECORD.xlsx"
²Ä5¦æ³o¥y
With Workbooks.Open(fd & fs)
´N­n§ï¦¨
With Workbooks.Open(fs)

Join(Ar, "¡B"): Erase ³o¥y¬O¤°»ò·N«ä¡H
µ{¦¡»yªk¤£¯à¥uŪ¤@¥b¡A¦b¦P¤@¦æ±Ô­z¨Ï¥Î«_¸¹¡A¬Û·í©ó¨â¦æ±Ô­z
Join(Ar, "¡B") ¡÷  ·|±o¨ì°}¦C¤¸¯À¥Î¹y¸¹¡B³s±µªº¦r¦ê
Erase Ar ¡÷  ¬O²MªÅ°}¦C

µ{¦¡¼g±o¹ï¤£¹ï¡A°õ¦æ¤@¤U´Nª¾¹Dµ²ªG°Õ
§@ªÌ: 198188    ®É¶¡: 2013-3-9 23:15

¦^´_ 21# Hsieh

[attach]14320[/attach]
        ·PÁ¸ÑÄÀ¡AÁöµM¤£¤Ó©ú¥Õ¡A¦ý·|¦h¹Á¸Õ¡C
¥t¥~§Ú·Q°Ý
¦pªGH Äæ¦pªþ¥ó¨º¼Ë¦X¨Ö¡A¬O§_µLªkŪ¨ú¡H
¥u¦³214110 ¦³¸ê®Æ
¤U­±´X­Ó¬O¤£¬Oµ¥©óªÅ®æ¨S¸ê®Æ¡H
210695
214162
213924
212340
212341
211914
211915
212857
§@ªÌ: Hsieh    ®É¶¡: 2013-3-9 23:29

¥»©«³Ì«á¥Ñ Hsieh ©ó 2013-3-10 10:14 ½s¿è

¦^´_ 22# 198188
³o¼Ëªºµ{¦¡»P¼Ó¤Wµ{¦¡½X¤ñ¸û¬Ý¬ÝÀ³¸Ó´N®e©ö¤F¸Ñ
  1. Sub ex()
  2. Dim Sh As Worksheet, Rng As Range, C As Range, Ar()
  3. fd = ThisWorkbook.Path & "\"  '¸ê®Æ¨Ó·½¥Ø¿ý
  4. fs = "DOCS RECEIVED N RELEASED RECORD.xlsx" '¸ê®Æ¨Ó·½ÀÉ®×(§t°ÆÀɦW)
  5. With Workbooks.Open(fd & fs)
  6.   Set Sh = .Sheets("¦¬¥ó°O¿ý")
  7.       With ThisWorkbook.Sheets("State")
  8.          For Each A In .Range(.[A2], .Cells(.Rows.Count, 1).End(xlUp))
  9.             Set Rng = Sh.Columns("D").Find(A, lookat:=xlWhole)
  10.             If Not Rng Is Nothing Then
  11.                For Each C In Sh.Range(Rng, Sh.Cells(Sh.Rows.Count, 4).End(xlUp))
  12.                   If C = A And InStr(UCase(C.Offset(, 4).MergeArea(1)), "OBL") > 0 Then
  13.                      ReDim Preserve Ar(s)
  14.                      Ar(s) = C.Offset(, 4).MergeArea(1)
  15.                      s = s + 1
  16.                   End If
  17.                 Next
  18.             If s > 0 And A.Offset(, 9) = "" Then
  19.                A.Offset(, 9) = Join(Ar, "¡B")
  20.                Erase Ar
  21.                s = 0
  22.                   Else
  23.                A.Offset(, 9) = ""
  24.             End If
  25.             End If
  26.          Next
  27.       End With
  28.     .Close
  29. End With
  30. End Sub
½Æ»s¥N½X

§@ªÌ: 198188    ®É¶¡: 2013-3-10 00:17

¦^´_ 23# Hsieh


    ­ì²z©ú¥Õ¡A¥u¬O»yªk¥Îªk¥½²M´·¦p¦ó¥Î¡AÁ¡I
¦pªG¦X¨Ö´X­ÓÀx¦s®æ¬O§_Ū¤£¤F¡H¦p¤W¹Ï¡H
§@ªÌ: Hsieh    ®É¶¡: 2013-3-10 09:21

¦^´_ 24# 198188
µ½¥ÎF1»¡©ú»P³v¦æ°»¿ù¤~¯à¹ï»yªk¹ý©³¤F¸Ñ
§A°Ý¦X¨ÖÀx¦s®æ¬O§_¥i¦æ?
ªí¥Ü§A®Ú¥»¨S¦³°õ¦æ´ú¸Õ
¨S¦³«i®ð´ú¸Õ¥u·|Åý§A¥Ã»·°±¹y
°£«D¦³ÃÒ©ú¼Ó¤Wµ{¦¡½XµLªk¹F¦¨»Ý¨D
¥B»¡©ú²M·¡°ÝÃDÂI¡A§_«h¦¹°ÝÃD±N¤£¦A¦^À³
§@ªÌ: 198188    ®É¶¡: 2013-3-10 10:07

¦^´_ 25# Hsieh


    ¦X¨Ö¤@°Ý¡A¤§«e¤w¸Õ¹L¡A¥u¦³²Ä¤@­Ó¥iŪ¨ú¡A¨ä§E¬OªÅ®æ¡C§Ú°ÝÃD¼g±o¤£²M·¡¡A©êºp¡C
À³¸Ó¬O¤£¬O¦³¤èªk°µ¨ì¡H
§@ªÌ: Hsieh    ®É¶¡: 2013-3-10 10:18

¦^´_ 26# 198188
§A«ç»ò´ú¸Õªº?
[attach]14323[/attach]
§@ªÌ: GBKEE    ®É¶¡: 2013-3-10 15:16

¦^´_ 20# 198188
With Sheet2                 (³o¥y¬O§_§ïWith W:\Payment Daily Report\DOCS RECEIVED N RELEASED RECORD.xlsx ¡H¡^¦ý¬O¦n¹³¤£¹ï¡H¡H
¦pªG§Ú¼g³o¥y´À¥N¤W­±¨â¥yfs = "W:\PIHK\DOCS RECEIVED N RELEASED RECORD.xlsx"
²Ä5¦æ³o¥y
With Workbooks.Open(fd & fs)
´N­n§ï¦¨
With Workbooks.Open(fs)
  1.              With Workbooks.Open(fs)
  2.                      Set Sh=.Sheets("¦¬³æ°O¿ýSHEET")
  3.              End With

  4.               With Sh  '->¦p¦¹ Sh ¤w´À¥N¬°¬°W:\Payment Daily Report\DOCS RECEIVED N RELEASED RECORD.xlsx"ªº ¦¬³æ°O¿ýSHEET
  5.             
  6.                End With
½Æ»s¥N½X

§@ªÌ: 198188    ®É¶¡: 2013-3-10 20:34

¦^´_ 27# Hsieh


    ²{¦b¥i¥H¤F¡A¥i¯à¬Oexcel¦³ÂI½Ä¬ð¡C
¤£ª¾¹D¬°¤°»ò¦³®É­Ôexcelªºµ{¦¡¥»¨­¤@ª½¨S°ÝÃD¡A¦ý¬O¦³®É­Ô·|¬ðµM¥X²{°ÝÃD¡A¦ý¬O­«·s±Ò°Êexcel «á©ÎªÌ­«·s±Ò°Ê¹q¸£«á¡A´N¨S¦³°ÝÃD¤F¡C
§@ªÌ: 198188    ®É¶¡: 2013-3-10 20:53

¦^´_ 28# GBKEE
  1. Sub Ex()
  2. Dim Sh As Worksheet, Rng As Range, C As Range, Ar()
  3.     Dim R As Range, E As Range
  4.     With Sheets("State")                         '*** ¶·§ï¬°: Test.xlsmªºState Sheet
  5.         Set R = .Cells(1, "a")          'A1¶}©l
  6.                         
  7.          fs = "C:\Documents and Settings\USER\®à­±\DOCS RECEIVED N RELEASED RECORD.xlsx"
  8. With Workbooks.Open(fs)
  9.   Set Sh = .Sheets("¦¬¥ó°O¿ý")
  10.   Do Until R = "" 'Â÷¶}°j°éªº±ø¥ó:  AÄ檺 Àx¦s®æ=""
  11.       With Sh '*** ¶·§ï¬°: W:\Payment Daily Report\DOCS RECEIVED N RELEASED RECORD.xlsx"
  12.               
  13.                 Set Rng = .Columns("D").Find(R, lookat:=xlWhole)
  14.                  If Not Rng Is Nothing Then
  15.                     With .Columns("D")
  16.                         .Replace R, "=ABC", xlWhole                 '­×§ï"´M§äªº¦r¦ê" = ¨S©w¸qªº¦WºÙ
  17.                         Set Rng = .SpecialCells(xlCellTypeFormulas, xlErrors) 'Àx¦s®æ¦³¿ù»~­Èªº¯S©w½d³ò
  18.                         Rng.Value = R                               '¨S©w¸qªº¦WºÙ §ï¦^ "´M§äªº¦r¦ê"
  19.                         For Each E In Rng.Offset(0, 4)              'DÄæ¦ì²¾4Äæ=HÄæ
  20.                             If InStr(UCase(E), "OBL") Then          'HÄ檺¦r¤¸¤º¥]§t"OBL"¤T­Ó¦r
  21.                                                                     'UCase(E) Âà´«¬°¤j¼g
  22.                                 R.Offset(0, 9) = E.Value            'R.Offset(0, 9)-> AÄæ¦ì²¾¨ì JÄæ
  23.                                 'Test.xlsmªºState Sheet->JÄæ=DOCS RECEIVED N RELEASED RECORD.xlsx"->HÄ檺¦r¤¸
  24.                                 Exit For    '¦³§ä¨ì "OBL" Â÷¶}°j°é                          '
  25.                             End If
  26.                        Next
  27.                     End With                '.Columns("D")
  28.                 End If
  29.             End With                        'Sheet2
  30.             Set R = R.Offset(1)             '¤U²¾¨ì A2
  31.      Loop
  32.     End With                                'Sheet1
  33. End With
  34. End Sub
½Æ»s¥N½X
³o¼Ë´N¥i¥H¤F¡C
¤£¹L³o­Óµ{¦¡¡A¦pªGDOCS RECEIVED N RELEASED RECORD.xlsxªºHÄæ´X¦C¬O¦X¨Öªº¸Ü¡A´NŪ¤£¤F¥u¦³²Ä¤@­Ó¤~·|¦³¸ê®Æ¡A²Ä¤G¦C¶}©l´NµL¸ê®Æ¡C
§@ªÌ: mark15jill    ®É¶¡: 2013-3-11 08:19

¦^´_  GBKEE


With Sheet1                        (³o¥y¬O§_§ïWith State sheet?)
With Sheet2      ...
198188 µoªí©ó 2013-3-9 23:00



    With Sheet1                        (³o¥y¬O§_§ïWith State sheet?)  ³oºØ¼gªkÀ³¸Ó·|¥X²{¿ù»~
°£«D¦³¥t¥~«Å§i
§@ªÌ: 198188    ®É¶¡: 2013-3-13 11:31

¦^´_ 28# GBKEE

If Worksheets("OHC").Range("G" & i) - Date <= 2 Then
    Worksheets("OHC").Range("G" & i).Interior.Color = RGB(255, 251, 45)
    Worksheets("OHC").Range("G" & i).Font.ColorIndex = RGB(217, 24, 9)
    End If

½Ð°Ý¤j¤j¡AIf Worksheets("OHC").Range("G" & i) - Date <= 2 Then ³o¥y­þ¸Ì¥X²{°ÝÃD¤F¡H
§@ªÌ: mark15jill    ®É¶¡: 2013-3-13 12:19

¦^´_  GBKEE

If Worksheets("OHC").Range("G" & i) - Date
198188 µoªí©ó 2013-3-13 11:31



    If Worksheets("OHC").Range("G" & i) - Date   
  §â¨â¬q¤À¶}
If Worksheets("OHC").Range("G" & i)
-
Date
§@ªÌ: GBKEE    ®É¶¡: 2013-3-13 12:30

¦^´_ 32# 198188
If Worksheets("OHC").Range("G" & i) - Date <= 2 Then ³o¥y­þ¸Ì¥X²{°ÝÃD¤F¡H
±ø¥ó¦¡:  Range("G?")(<- ¥²»Ý¬O¤é´Á) - Date(·í¤Ñ¤é´Á)<=2(¤Ñ)
§A»¡¥X²{°ÝÃD¤F ,½Ð»¡©ú¥Õ!!
§@ªÌ: 198188    ®É¶¡: 2013-3-13 12:48

¦^´_ 34# GBKEE


    ¨â­Ó³£¬O¤é´Á¡A¦ý¬O¹q¸£»¡typing mistake, ©Ò¥H§Ú·Q°Ý¬O¤£¬O§Úªº»yªk¦³¿ù¡H
§@ªÌ: GBKEE    ®É¶¡: 2013-3-13 14:23

¦^´_ 35# 198188
typing mistake ªºÂ½Ä¶¬O¿é¤J¿ù»~
½ÐÀˬd Range("g?")¬O§_¬O¼Æ¦r,©Î¶Ç¤WÀɮ׬ݬÝ
§@ªÌ: Hsieh    ®É¶¡: 2013-3-13 14:53

¦^´_ 32# 198188


    À³¸Ó³o¥y¿ù»~
Worksheets("OHC").Range("G" & i).Font.ColorIndex = RGB(217, 24, 9)
ColorIndex À³¸Ó¬O¼Æ­È¤£¥i¨Ï¥ÎRGB
¥i§ï¦¨
Worksheets("OHC").Range("G" & i).Font.Color = RGB(217, 24, 9)
§@ªÌ: apolloooo    ®É¶¡: 2013-3-15 09:34

like ·|¤ñ¸û¦n¥Î¡C




Åwªï¥úÁ{ ³Â»¶®a±Ú°Q½×ª©ª© (http://forum.twbts.com/)