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

[µo°Ý] ¨D§U~Ãö©óvbaªºµ{¦¡!

¥»©«³Ì«á¥Ñ FAlonso ©ó 2011-1-19 14:33 ½s¿è

¦Û¤v°µ¤F¤@­Ó,µ¹¨ä¥L·|­û¬Ý¬Ý,excel¤å¥óµy¬°°µ¤F¤@¨Ç­×§ï,§âªÅcolumnµ¹§R±¼
¤£¯à¤U¸üªº¸Ü,½Ð¬Ý¤U¦Cµ{¦¡
  1. Sub chooseyellowcell2()
  2. Dim i As Integer, myfinalrow As Integer
  3. Dim mycell As Range, mycolumn As Range, mycell2 As Range, mytarget As Range, mybaseline As Range, mycheck As Range
  4. Dim checkstatus As Boolean

  5. ThisWorkbook.Activate

  6. For i = 2 To Worksheets.Count
  7.     Sheets(i).Activate
  8.     myfinalrow = ActiveSheet.Range("A2").End(xlDown).Offset(1).Row
  9.         For Each mycell In ActiveSheet.Range("A1", Range("IV1").End(xlToLeft))
  10.             If mycell.Value <> "" Then
  11.             Set mycolumn = Range(mycell, mycell.End(xlDown))
  12.                 For Each mycell2 In mycolumn
  13.                     If mycell2.Interior.ColorIndex = 6 Then
  14.                         checkstatus = False
  15.                         Set mybaseline = mycell2.Offset(1)
  16.                         Set mycheck = mycell2
  17.                             If mybaseline.Value = "" Then
  18.                             mybaseline.Value = "µLªk­pºâ"
  19.                             Exit For
  20.                             Else
  21.                             Do
  22.                                 If mycheck.Value >= mybaseline.Value Then
  23.                                 ActiveSheet.Cells(myfinalrow, mycheck.Column) = mybaseline.Row - mycheck.Row
  24.                                 checkstatus = True
  25.                                 Exit Do
  26.                                 Else
  27.                                 Set mycheck = mycheck.Offset(-1)
  28.                                 End If
  29.                             Loop While checkstatus = False And IsNumeric(mycheck) = True
  30.                                 If checkstatus = False Then
  31.                                 mycheck.End(xlDown).Offset(1).Value = "µL¶ñÅv"
  32.                                 End If
  33.                             End If
  34.                     End If
  35.                 Next
  36.             End If
  37.         Next
  38. Next

  39. End Sub
½Æ»s¥N½X
­pºâ°£Åv¤é.rar (289.3 KB)
80 ¦r¸`¥H¤º
¤£¤ä«ù¦Û©w¸q Discuz! ¥N½X

TOP

¦^´_ 20# Hsieh


§A¦n~
¦ý¬O¨C­Ó¦~«×¦³°£Åvªº¤½¥q¤£¤Ó¤@¼Ë~
©Ò¥H­n§â¥¦¦X¨Ö¨ì¦P¤@±i¤u§@ªí¤¤¦ü¥G¦³¤@ÂI§xÃø!
ÁÂÁÂ!

TOP

¦^´_ 22# candy516
³o¼Ë¥i¯à³Â·Ð¤@ÂI
µ{¦¡±N¶ñ¤J¶ñÅv¤é¼Æ¡A¨Ã±N10¤é¤º¶ñÅv¦W³æ¦C¥X
½Ð±Nµ{¦¡½X¸m©óSheet1¼Ò²Õ
  1. Sub ¶ñÅv()
  2. Dim A As Range, Ar()
  3. Set dic = CreateObject("Scripting.Dictionary")
  4. Set myday = CreateObject("Scripting.Dictionary")
  5.           ReDim Preserve Ar(z)
  6.           Ar(z) = Array("¤½¥q", "¦~«×", "¶ñÅv¤é¼Æ")
  7.           z = z + 1

  8. Dim Sh As Worksheet
  9. For j = Sheets.Count To 1 Step -1
  10. Set Sh = Sheets(j)
  11.   With Sh
  12.      If .Name <> Me.Name Then
  13.      Set rng = .Range(.[B1], .Cells(1, .Columns.Count).End(xlToLeft))
  14.         If Application.CountBlank(rng) > 0 Then rng.SpecialCells(xlCellTypeBlanks).EntireColumn.Delete
  15.         For r = .Cells(.Rows.Count, 1).End(xlUp).Row To 3 Step -1
  16.         Set A = .Cells(r, 1)
  17.            myday(A.Value) = temp
  18.            temp = A.Value
  19.         Next
  20.         Else
  21.         For Each A In .Range(.[A2], .Cells(.Rows.Count, 1).End(3))
  22.         dic(A & Year(A.Offset(, 1))) = A.Offset(, 1)
  23.         Next
  24.     End If
  25.   End With
  26. Next
  27. For Each Sh In Sheets
  28.   With Sh
  29.   If .Name < Me.Name Then
  30.   k = 2: dn = .Name
  31.     Do Until .Cells(1, k) = ""
  32.        .Columns(k + 1).Insert
  33.        f = .Cells(1, k)
  34.        Set A = .Columns("A").Find(dic(f & dn))
  35.        If A Is Nothing Then GoTo 20
  36.        d = myday(A.Value)
  37.        With Sheets(CStr(Year(d)))
  38.           Set b = .Columns("A").Find(d)
  39.           Set c = .Rows(1).Find(f)
  40.           If b Is Nothing Or c Is Nothing Then cnt = "µL¶ñÅv": GoTo 10
  41.           x = b.Row
  42.           y = c.Column
  43.           test = .Cells(x, y)
  44.        End With
  45.        r = A.Row: cnt = 1
  46.        Do Until r = 2 Or .Cells(r, k) >= test
  47.        r = r - 1
  48.        cnt = cnt + 1
  49.        Loop
  50.        If r = 2 Then cnt = "µL¶ñÅv"
  51. 10
  52.        .Cells(A.Row, k + 1) = cnt
  53.        If IsNumeric(cnt) And cnt <= 10 Then
  54.           ReDim Preserve Ar(z)
  55.           Ar(z) = Array(f, dn, cnt)
  56.           z = z + 1
  57.        End If
  58.       
  59. 20
  60.        k = k + 2
  61.     Loop
  62.   End If
  63.   End With
  64. Next
  65. Set dic = Nothing
  66. Set myday = Nothing
  67. With Worksheets.Add
  68. .[A1].Resize(z, 3) = Application.Transpose(Application.Transpose(Ar))
  69. .Move
  70. End With
  71. End Sub
½Æ»s¥N½X
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

¦^´_ 23# Hsieh
ÁÂÁ§AªºÀ°¦£!
§Ú¥Ø«e¬O¤À¨â­Óµ{¦¡°õ¦æ¡G
²Ä¤@¡G¥ý±N©Ò¦³ªÑ»ùªºÄæ¦ì³£§R°£
Sub delcol()
Dim i%, c As Range
Set c = Columns(2)
For i = 4 To [iv1].End(1).Column Step 2
Set c = Union(c, Columns(i))
Next
c.Delete
End Sub
²Ä¤G¡G¦A±NªÅ®æ§R°£¡A§â¸ê®Æ©¹¤W¸É¡A¦b«á¦A±N¨äµ²ªGÂà¸m¡C
Sub ex1()
Columns("B:CF").SpecialCells(xlCellTypeBlanks).Delete Shift:=xlUp
End Sub
¦]¬°§Ú«á¨Ó·Q»¡¡A§Ú¥ý¤£­n³]©w©Ò¿×¦³§¹¦¨¶ñÅvªº¤Ñ¼Æ¡A
³o¼Ë¼u©Ê¤ñ¸û¤j!¦Ó§Ú¨ì®É­Ô·Q¬Ý"´X¤Ñ"§¹¦¨¶ñÅvªº¤½¥q¡A
¦A¥ÎEXCEL¿z¿ï¥\¯à§Y¥i!
¯uªº«ÜÁÂÁ§A­@¤ßªºÀ°¦£!
^^

TOP

        ÀR«ä¦Û¦b : ¡i¦æµ½­n¤Î®É¡j¦æµ½­n¤Î®É¡A¥\¼w­n«ùÄò¡C¦p¿N¶}¤ô¤@¯ë¡A¥¼¿N¶}¤§«e¤d¸U¤£­n°±º¶¤õ­Ô¡A§_«h­«¨Ó´N¤Ó¶O¨Æ¤F¡C
ªð¦^¦Cªí ¤W¤@¥DÃD