I have a range rng
, let's say it covers A1:C5
. Now I want to modify the range, in this example taking out all cells in column B
(meaning B1:B5
). In the code below I simply defined it manually, but is there some way to tell VBA to use rng
as reference and "subtract" the cells I don't want?
Sub Test()
Dim rng As Range
Dim rngMod As Range
Set rng = ActiveSheet.Range("A1:C5")
Set rngMod = ActiveSheet.Range("A1:A5, C1:C5") '<-- can I somehow define this range by telling VBA to take out column B out of rng?
End Sub
For context: I have conditional formatting rules and would like the user to be able to adjust the ranges some rules are applied to (by selecting the cells he doesn't want to be formatted and clicking a button). My thinking is I'd have to copy the ranges (or their addresses) somwhere onto the worksheet and then I can go from there, but for this to work I need to be able to modify the range somehow.