+ Reply to Thread
Results 1 to 7 of 7

Setting varible to equal values of a # of cells

  1. #1
    Registered User
    Join Date
    08-18-2004
    Posts
    15

    Setting varible to equal values of a # of cells

    Is there a way of grabbing the values of a range of cells and assigning them to a string vairable.

    For example if I had RED, BLUE, WHITE in cells A1 to A3 respectively, how could I get my variable strColors=RedBlueWhite

    I have tried strColors=Range("A1:A3").value and that obviously did not work.

    Assistance Appreciated.

  2. #2
    Forum Expert Carim's Avatar
    Join Date
    04-07-2006
    Posts
    4,070
    Hi Mozart,

    I hope this will be music to you ...


    Sub RWB()
    Dim RWB As String
    RWB = Range("A1").Value & Range("A2").Value & Range("A3").Value
    End Sub


    HTH
    Cheers
    Carim

  3. #3
    Carim
    Guest

    Re: Setting varible to equal values of a # of cells

    Hi Mozart,

    I hope this will be music to you ...

    Sub RWB()
    Dim RWB As String
    RWB = Range("A1").Value & Range("A2").Value & Range("A3").Value
    End Sub

    HTH
    Cheers
    Carim


  4. #4
    Registered User
    Join Date
    08-18-2004
    Posts
    15
    Yes that would seem the way to do it but it could become painful if say your range was say 50 cells let alone 62k.

    Thanks

  5. #5
    Carim
    Guest

    Re: Setting varible to equal values of a # of cells

    Sub RWB()
    Dim RWB As String
    Dim i As Integer
    For i = 1 To 50
    RWB = RWB & Range("A" & i).Value
    Next i
    End Sub

    All the Best
    Carim


  6. #6
    Dana DeLouis
    Guest

    Re: Setting varible to equal values of a # of cells

    Would this work for you using the later versions of Excel.
    This demo starts at Cell A1 for a size of 50.

    Sub Demo()
    Dim Str As String
    Dim n As Long

    n = 50
    Str = Join(WorksheetFunction.Transpose(Range("A1").Resize(n)),
    vbNullString)
    End Sub

    --
    HTH. :>)
    Dana DeLouis
    Windows XP, Office 2003


    "mozart" <[email protected]> wrote in
    message news:[email protected]...
    >
    > Yes that would seem the way to do it but it could become painful if say
    > your range was say 50 cells let alone 62k.
    >
    > Thanks
    >
    >
    > --
    > mozart
    > ------------------------------------------------------------------------
    > mozart's Profile:
    > http://www.excelforum.com/member.php...o&userid=13314
    > View this thread: http://www.excelforum.com/showthread...hreadid=533112
    >




  7. #7
    Registered User
    Join Date
    08-18-2004
    Posts
    15
    Thanks Dana. That works nicely

+ 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