문제

Is it possible to refer to Rg in With Rg? I have a long with statement and I would like to pass the range specified in the With statement as a parameter. Is this possible?

With rg.OffSet(0, -1).Resize(ColumnSize:=1)

    'set conditional format
    Call SetConditionalFormat(rg.OffSet(0, -1).Resize(ColumnSize:=1))

    'I tried this but it didn't work
    Call SetConditionalFormat(.range)

End With

Sure I could simply repeat the rg.OffSet(0, -1).Resize(ColumnSize:=1) or assign it to a variable, but I'm curious if such a thing exists as referring to itself.

도움이 되었습니까?

해결책

In case with Range object you could use:

Call SetConditionalFormat(.Cells)

it's not a self-referring, but could help you to operate with target object.

다른 팁

I have seen prettier code but it works ;)

With rg.Offset(0, -1).Resize(ColumnSize:=1)

    Call SetConditionalFormat(.Parent.Range(.Address))

End With
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top