Logo 
Search:

MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

Passing Named Ranges

  Asked By: Muaz    Date: Jan 15    Category: MS Office    Views: 898
  

I've got a series of worksheet reformatting macros that I'm trying to
consolidate. Currently each macro has sections of identical code that
carry out the same reformatting but differ only in the range of cells
the reformatting is carried out on. Needless to say, this is becomming
a bit of a pain to manage and is certainly an inefficient way of
coding!

What I'd like to do is separate out the reformatting code into their
own routines, then call them whilst passing the name of the range I'd
like it to operate on. What I can't figure out is how to pass the
Named Range to the new proceedure.

Is anyone willing to take pity, and let me know?

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Yvonne Watkins     Answered On: Jan 15

: What I'd like to do is separate out the reformatting code  into
: their own routines, then call them whilst passing  the name of
: the range  I'd like it to operate on. What I can't figure out
: is how to pass the named  Range to the new proceedure.

The Range() method can handle named ranges. Here's a lame
example.


Foo (Sheets("Accounts").Range("Zip"))


Private Sub Foo(MyRange As Range)

MyRange.Font.Bold = True

End Sub

 
Didn't find what you were looking for? Find more on Passing Named Ranges Or get search suggestion and latest updates.




Tagged: