求助一个问题 如图 需要一串代码
vba吧
全部回复
仅看楼主
level 2
求助一个问题 如图 需要一串代码[小乖]
2019年12月17日 03点12分 1
level 1
随手写了下,没验证,你试试
Sub xxx()
Dim datenow, c, myrange, myrow, ws As Worksheet
Set ws = ThisWorkbook.Sheets(1)
c = ws.Range("a65500").End(xlUp).Row
For Each myrange In Range("a1:a" & c)
If myrange = Date Then
myrow = myrange.Row
Rows((myrow - 1) & ":" & (myrow - 3)).Select
Selection.EntireRow.Hidden = True
Exit Sub
End If
Next
End Sub
2019年12月25日 02点12分 2
谢谢
2020年01月06日 06点01分
level 12
暖贴
2019年12月25日 09点12分 3
level 5
@Doult_跳 的基础上修改的,应该满足需求
Sub xxx()
Dim datenow, c, d, myrange, myrow, ws As Worksheet
Set ws = ThisWorkbook.Sheets(1)
c = ws.Range("a65500").End(xlUp).Row
'取消隐藏所有
Rows("2:65536").Select
Selection.EntireRow.Hidden = False
For Each myrange In Range("a1:a" & c)
If myrange = Date Then
myrow = myrange.Row
'Rows((myrow - 1) & ":" & (myrow - 3)).Select
'Selection.EntireRow.Hidden = True
Rows("2:" & (myrow - 7)).Select
Selection.EntireRow.Hidden = True
Rows((myrow) & ":" & c).Select
Selection.EntireRow.Hidden = True
Exit Sub
End If
Next
End Sub
2020年01月07日 15点01分 4
level 7
Cells.Select '选中所有单元格
Selection.EntireRow.Hidden = False '取消所有隐藏
c = Range("a65500").End(xlUp).Row '取A列非空行标,赋值给c
Set Rg = Columns(1).Find(Date) '在第一列中匹配当天日期
If Rg Is Nothing Then
MsgBox "无匹配到指定日期"
Else
If Rg.Row > 3 Then '如果当天日期小于3号,则不能显示三天内容
Rows(Rg.Row & ":" & c).EntireRow.Hidden = True
Rows("2:" & Rg.Row - 4).EntireRow.Hidden = True
Else
Rows(Rg.Row & ":" & c).EntireRow.Hidden = True
End If
End If
2020年07月02日 07点07分 5
想到了小于3日的情况,实战经验多哈
2024年09月04日 03点09分
1