gpt4 book ai didi

vba - 突出显示行直到特定列

转载 作者:行者123 更新时间:2023-12-04 20:30:49 28 4
gpt4 key购买 nike

如何修改我的代码以选择直到 L 列而不是整行的行?

子审判()

Dim c As Range
Dim rngG As Range
For Each c In Intersect(ActiveSheet.UsedRange, Columns("f"))
If c >= 1 Then

If rngG Is Nothing Then Set rngG = c.EntireRow
Set rngG = Union(rngG, c.EntireRow)
End If
Next c
rngG.Select

结束子

最佳答案

只需添加一个相交,

    If rngG Is Nothing Then Set rngG = c.EntireRow
Set rngG = Union(rngG, c.EntireRow)

... 喜欢,
    If rngG Is Nothing Then Set rngG = intersect(range("A:L").entirecolumn, c.EntireRow)
Set rngG = Union(rngG, intersect(range("A:L").entirecolumn, c.EntireRow))

TBH,我不确定 .entirecolumn 是否完全必要,但我不久前遇到了这个问题,添加 .entirecolumn 是解决方法。
Dim c As Range, rngG As Range

For Each c In Intersect(ActiveSheet.UsedRange, Columns("f"))
If c >= 1 Then
If rngG Is Nothing Then Set rngG = intersect(range("A:L").entirecolumn, c.EntireRow)
Set rngG = Union(rngG, intersect(range("A:L").entirecolumn, c.EntireRow))
End If
Next c
rngG.Select

关于vba - 突出显示行直到特定列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51238593/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com