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.
题
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