Syntax needed for With
Hi Paul
with is usually used to avoid typing the object reference over and over
again. So kind of reduced typing. to give you an example
1. Without using With:
sub foo_1()
Dim wks as worksheet
dim rng as worksheet
set wks = activesheet
set rng = wks.range("A1:A100")
rng.value = 1
rng.offset(0,1).value = 2
rng.offset(0,2).value = 3
wks.printout
end sub
2. Using with
sub foo_2()
Dim wks as worksheet
dim rng as worksheet
set wks = activesheet
with wks
set rng = .range("A1:A100")
with rng
.value = 1
.offset(0,1).value = 2
.offset(0,2).value = 3
end with
.printout
end with
end sub
--
Regards
Frank Kabel
Frankfurt, Germany
"count" schrieb im Newsbeitrag
...
Hi,
Task at hand is to hide those columns, whose headings are on the
Named Range
"Elements" list (stored aside)
I used to do it via plain looping but I saw recently clever usage of
With
construct.
I would like to learn how to put With into use and start using
objects more.
TIA
Paul
|