+ Reply to Thread
Results 1 to 4 of 4

VBA - Cell Assignment

  1. #1
    Forum Contributor
    Join Date
    12-22-2004
    Location
    Kokomo, Indiana
    Posts
    236

    Question VBA - Cell Assignment

    Group,
    After I select a cell how do I assign the contents of the cell into a variable? Seems trivial, but it has me stuck.

    Learning VBA and loving it........

    Tony

  2. #2
    Registered User
    Join Date
    12-22-2003
    Location
    Texas
    Posts
    90
    dim var1 as ________

    var1 = activecell

    where var1 is the variable name

    goto the help menu and type in dim. I will help determine what should go in the above underlined section.

    For example, if the value in the cell is a serial number with leading zeros, dim as a string. If you were to dim as a double (number) then it might leave off the leading zeros.
    Last edited by barrfly; 07-27-2005 at 11:31 AM.
    Barrfly

  3. #3
    Bob Phillips
    Guest

    Re: VBA - Cell Assignment

    myVar = Activecell

    but no need to select it

    myVar = Range("A1").Value

    --
    HTH

    Bob Phillips

    "ajocius" <[email protected]> wrote in
    message news:[email protected]...
    >
    > Group,
    > After I select a cell how do I assign the contents of the cell
    > into a variable? Seems trivial, but it has me stuck.
    >
    > Learning VBA and loving it........
    >
    > Tony
    >
    >
    > --
    > ajocius
    > ------------------------------------------------------------------------
    > ajocius's Profile:

    http://www.excelforum.com/member.php...o&userid=17695
    > View this thread: http://www.excelforum.com/showthread...hreadid=390560
    >




  4. #4
    Gary Keramidas
    Guest

    Re: VBA - Cell Assignment

    somethink like this should work, not sure what you have in the cell, though

    Dim MyText As String

    Sub Mytest()
    MyText = Range("b2").Value
    MsgBox MyText
    End Sub

    --


    Gary


    "ajocius" <[email protected]> wrote in
    message news:[email protected]...
    >
    > Group,
    > After I select a cell how do I assign the contents of the cell
    > into a variable? Seems trivial, but it has me stuck.
    >
    > Learning VBA and loving it........
    >
    > Tony
    >
    >
    > --
    > ajocius
    > ------------------------------------------------------------------------
    > ajocius's Profile:
    > http://www.excelforum.com/member.php...o&userid=17695
    > View this thread: http://www.excelforum.com/showthread...hreadid=390560
    >




+ 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