Results 1 to 4 of 4

Thread: [RESOLVED] How to join the contents of two cells into one?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2011
    Posts
    110

    Resolved [RESOLVED] How to join the contents of two cells into one?

    Hello,
    I tried:

    Code:
    Sub combine()
        Dim str(1 To 2) As String 'create the matrix
        Dim final As String 'create the string
        
        str(1) = ActiveCell.Text 'takes the value
        str(2) = ActiveCell.Offset(0, 1).Text 'takes the other
        final = Join(str, " ") 'join
        ActiveCell.Offset(0, 1).Text = final 'print
    End Sub
    But it results in error 424

  2. #2

    Thread Starter
    Lively Member
    Join Date
    Jan 2011
    Posts
    110

    Re: How to join the contents of two cells into one?

    But it works with ActiveCell.Offset(0, 1) = final instead of ActiveCell.Offset(0, 1).Text = final

  3. #3
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: How to join the contents of two cells into one?

    the text property of cells is read only
    it is used to read the displayed (formatted), content of the cell, assigned by the value property
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Jan 2011
    Posts
    110

    Re: How to join the contents of two cells into one?

    Thanks. Now that I understand the difference among. text,. value,. and formula. FormulaR1C1

Posting Permissions

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



Click Here to Expand Forum to Full Width