Question

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.

Was it helpful?

Solution

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.

OTHER TIPS

I have seen prettier code but it works ;)

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

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

End With
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top