|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
本帖最后由 cmo9020 于 2023-2-24 19:26 编辑
test.rar
(16.12 KB, 下载次数: 5)
请问各位专业的导师
A1单元格是年
B1单元格是月
下拉选项后日期会变动
我要从sheet6 A列找出相同日期,然后以日期做为笔数
把笔数做累计加总在反黄色的区域
只要A1单元格或B1单元格和日有做变动,就会自动秀出每日的几笔笔数
像橘色部份为答案
请问要如何修改代码?麻烦请导师们指导一下,谢谢
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$1" Or Target.Address = "$B$1" Then
Dim row As Integer
For row = 3 To 13
If row Mod 2 = 1 Then
If row <> 3 And row <> 5 And row <> 7 And row <> 9 And row <> 11 And row <> 13 Then
Range("C" & row & ":I" & row).ClearContents
Else
Range("C" & row & ":I" & row).Clear
End If
End If
Next row
Dim FirstDay As Date
FirstDay = DateSerial(Val(Range("A1").Value), Val(Range("B1").Value), 1)
Dim i As Integer
For i = 0 To 6
Next i
Dim j As Integer
Dim CurrentDate As Date
CurrentDate = FirstDay
For j = 0 To 5
For i = 0 To 6
If i = Weekday(CurrentDate, vbSunday) - 1 And month(CurrentDate) = Val(Range("B1").Value) Then
Cells(j * 2 + 3, i + 3) = Day(CurrentDate)
CurrentDate = CurrentDate + 1
End If
Next i
Next j
End If
End Sub
|
|