+ Reply to Thread
Results 1 to 3 of 3

Thread: Copy a range to string

  1. #1
    Registered User
    Join Date
    12-02-2008
    Location
    USA
    Posts
    30

    Copy a range to string

    This is very simple question.

    I have names in the cells K10 to K12. I want to copy them to a string. Tried the following code, but the output is only cell k10 value.
    Sub fill()
    Dim x As Range, st As Variant
    
    Set x = ActiveSheet.Range("k10:k12")
    
    
    st = x.Value
    [c1] = st
    End Sub
    I know this can be implemented using a for loop, but want to see the mistake in the above method.
    Thanks

  2. #2
    Forum Guru TMShucks's Avatar
    Join Date
    07-15-2010
    Location
    Manchester, England
    MS-Off Ver
    MSO 2003 & 2007
    Posts
    6,225

    Re: Copy a range to string

    Try (untested)

     
    Dim st as string
    st = Join(Application.Transpose(Application.Transpose(Range("k10:k12"))))

    Regards, TMS

  3. #3
    Registered User
    Join Date
    12-02-2008
    Location
    USA
    Posts
    30

    Re: Copy a range to string

    Getting Run time error 5
    Invalid procedure call or argument

+ 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.2.0