看了下,你不停的更改数据表结构,代码就要稍微修改,最好还是了解下基本的VBA知识吧
以下代码仅适用你这个表
- Sub rxtj()
- Dim arr
- Dim sht As Worksheet
- For Each sht In Sheets
- If InStr(sht.Name, "周") Then
- sht.[b2:zz31].Clear
- End If
- Next
- rq = DateAdd("d", -(Weekday(Date) - 2), Date)
- arr = Sheets("日度").[a2].CurrentRegion
- For y = 2 To UBound(arr, 2)
- For i = 0 To 140
- If arr(1, y) = DateAdd("ww", -20, rq) + i Then
- icol = Sheets("周" & Choose(Weekday(DateAdd("ww", -20, rq) + i), "日", "一", "二", "三", "四", "五", "六")).Range("zz2").End(xlToLeft).Column + 1
- Sheets("日度").Cells(2, y).Resize(30, 1).Copy Sheets("周" & Choose(Weekday(DateAdd("ww", -20, rq) + i), "日", "一", "二", "三", "四", "五", "六")).Cells(2, icol)
- End If
- Next
- Next
- MsgBox "ok!"
- End Sub
复制代码
|