+ Reply to Thread
Results 1 to 3 of 3

Using Parameters in Visual Basic

  1. #1

    Using Parameters in Visual Basic

    Hi, I'm creating a VB script and I've named a particular cell using
    the code

    Cobrand = Range("F10").Text

    However, I'm trying to select Cobrand in a subsequent line of code,
    and I want to be able to use Cobrand in the code below instead of F10

    Range("F10").select

    But when I try to use the following statement it doesn't work, any
    suggestions???

    Range(Cobrand).Select


  2. #2
    George Nicholson
    Guest

    Re: Using Parameters in Visual Basic

    Cobrand = Range("F10").Text
    assigns the *characters inside* cell F10 to Cobrand, not the address "F10".
    Try:
    Cobrand = Range("F10").Address

    Cobrand will then equal the characters "$F$10" and
    Range(Cobrand).Select
    should work

    Alternatively, you could also:
    Dim Cobrand as Range
    Set Cobrand = Range("F10")
    Cobrand.Select

    HTH,
    --
    George Nicholson

    Remove 'Junk' from return address.


    <[email protected]> wrote in message
    news:[email protected]...
    > Hi, I'm creating a VB script and I've named a particular cell using
    > the code
    >
    > Cobrand = Range("F10").Text
    >
    > However, I'm trying to select Cobrand in a subsequent line of code,
    > and I want to be able to use Cobrand in the code below instead of F10
    >
    > Range("F10").select
    >
    > But when I try to use the following statement it doesn't work, any
    > suggestions???
    >
    > Range(Cobrand).Select
    >




  3. #3
    Michael Gill
    Guest

    RE: Using Parameters in Visual Basic

    Hi,

    The value of cobrand in your last command is whatever the text was in cell
    F10. Instead of setting cobrand = range("F10").text set it to cobrand =
    "F10".

    This will allow your Range(Cobrand).Select statement to work.

    Michael

    "[email protected]" wrote:

    > Hi, I'm creating a VB script and I've named a particular cell using
    > the code
    >
    > Cobrand = Range("F10").Text
    >
    > However, I'm trying to select Cobrand in a subsequent line of code,
    > and I want to be able to use Cobrand in the code below instead of F10
    >
    > Range("F10").select
    >
    > But when I try to use the following statement it doesn't work, any
    > suggestions???
    >
    > Range(Cobrand).Select
    >
    >


+ 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