+ Reply to Thread
Results 1 to 5 of 5

Passing a range into a VBA function

Hybrid View

  1. #1
    Floyd
    Guest

    Passing a range into a VBA function

    All:

    I am attempting to pass a cell such as $C10 into a function. Inside
    the function, I have the following code:

    Dim Rng1 as Range
    Set Rng1 = Range("$C10")

    This code segment works. Now, if I attempt to pass a named cell into
    the code, it compiles but gives the following error message when
    "Watched". <Expression not defined in context> Type = Empty

    Dim Rng1 as Range
    Set Rng1 = Range(NamedCell)

    Any suggestions?

    Thanks in advance.

    Cheers.


  2. #2
    Jim May
    Guest

    Re: Passing a range into a VBA function


    Set Rng1 = Range(NamedCell)

    must be:

    Set Rng1 = Range("NamedCell")

    HTH

    "Floyd" <batesf@pioneernrc.com> wrote in message
    news:1107993589.277662.155450@z14g2000cwz.googlegroups.com...
    > All:
    >
    > I am attempting to pass a cell such as $C10 into a function. Inside
    > the function, I have the following code:
    >
    > Dim Rng1 as Range
    > Set Rng1 = Range("$C10")
    >
    > This code segment works. Now, if I attempt to pass a named cell into
    > the code, it compiles but gives the following error message when
    > "Watched". <Expression not defined in context> Type = Empty
    >
    > Dim Rng1 as Range
    > Set Rng1 = Range(NamedCell)
    >
    > Any suggestions?
    >
    > Thanks in advance.
    >
    > Cheers.
    >




  3. #3
    Floyd
    Guest

    Re: Passing a range into a VBA function

    Mr. May,

    I apologize. The range itself is not names. It is being passed as
    reference with the name, NamedCell. For example, Function
    Testing(NamedCell as range)

    Thanks so much for your assistance.

    Cheers.


  4. #4
    Tim Williams
    Guest

    Re: Passing a range into a VBA function

    Set Rng1 =NamedCell

    tim


    "Floyd" <batesf@pioneernrc.com> wrote in message
    news:1107994707.664866.9200@l41g2000cwc.googlegroups.com...
    > Mr. May,
    >
    > I apologize. The range itself is not names. It is being passed as
    > reference with the name, NamedCell. For example, Function
    > Testing(NamedCell as range)
    >
    > Thanks so much for your assistance.
    >
    > Cheers.
    >




  5. #5
    Floyd
    Guest

    Re: Passing a range into a VBA function

    Mr. Williams,

    That worked perfectly.

    Thank you.


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1