Re: Syntax needed for With

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Bob Phillips (bob.phillips_at_notheretiscali.co.uk)
Date: 04/06/04


Date: Tue, 6 Apr 2004 14:03:38 +0100

Hi Paul,

There is no need for With this requirement.

There is nothing clever about With, it is just used to remove duplicated
object qualifying, thereby making the code more efficient as VBA does not
need to look up the reference each time, the With stores that reference in
memory, and makes the code easier to read IMO.

Here is the code you want

Dim col As Range

    For Each col In Active***.Range("Elements").Columns
        col.Hidden = True
    Next col

-- 
HTH
Bob Phillips
    ... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
"count" <no@spam.please> wrote in message
news:%23pK$EZ9GEHA.2224@TK2MSFTNGP12.phx.gbl...
> 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
>
>

Quantcast