返回列表 上一主題 發帖

[發問] 抓取篩選後儲存格內容至對應的工作表

回復 5# Michelle-W
請測試
資料-3.rar (27.11 KB)

TOP

回復 3# Michelle-W

資料.rar (1.1 MB)

TOP

回復 4# Kubi


非常感謝您的指點~~
還想請教一下...
若是假設B欄只是要記錄時間
(沒有專屬工作表,但要連同資料一起貼到專屬的工作表裡面的話)
以這組程式碼有辦法做更改嗎?

再次感謝 :)
資料-2.rar (27.23 KB)

TOP

回復 1# Michelle-W
請參考。
資料-1.rar (30.43 KB)

TOP

回復 2# c_c_lai


會出現1004的錯誤QQ

偵錯反黃的是這句
ActiveSheet.Name = lg.Value
這組程式碼太複雜了,我還看不懂>"<


在麻煩您幫忙看看
再次再次的感謝

TOP

回復 1# Michelle-W
試試看!
  1. Sub Ex()
  2.     Dim lg As Variant, ctn As Variant, xi As Integer
  3.     Dim dic As Object, sp As Variant, sh As Worksheet
  4.    
  5.     Set sh = Worksheets("05月")
  6.     Set dic = CreateObject("scripting.dictionary")
  7.    
  8.     With sh
  9.         For Each lg In .Range("B1:I1")
  10.             .Select
  11.             
  12.             dic(lg.Value) = ""
  13.             For Each ctn In .Range("A2:A7")
  14.                 If ctn.Offset(, lg.Column - 1) = "V" Then
  15.                     dic(lg.Value) = dic(lg.Value) + IIf(dic(lg.Value) = "", "", ",") + ctn.Value
  16.                 End If
  17.             Next
  18.             sp = Split(dic(lg.Value), ",")
  19.             '  Cells(15, lg.Column).Resize(UBound(sp) + 1) = Application.Transpose(Array(sp))    '  展示用
  20.             
  21.             For xi = 1 To Worksheets.Count
  22.                 If Worksheets(xi).Name = lg.Value Then Worksheets(xi).Select: Exit For
  23.             Next xi
  24.             If xi > Worksheets.Count Then
  25.                  Sheets.Add After:=Sheets(Worksheets.Count)
  26.                  ActiveSheet.Name = lg.Value
  27.             End If
  28.             With Worksheets(lg.Value)
  29.                 .[A1] = sh.[A1]
  30.                 .[B1] = lg.Value
  31.                 .[A2].Resize(UBound(sp) + 1) = Application.Transpose(Array(sp))
  32.                 .[B2].Resize(UBound(sp) + 1) = "V"
  33.             End With
  34.         Next
  35.     End With
  36. End Sub
複製代碼

TOP

        靜思自在 : 世上有兩件事不能等:一、孝順 二、行善。
返回列表 上一主題