Vba copy range & paste to a cell advice please

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,280
Office Version
  1. 2007
Platform
  1. Windows
Morning,

Trying to copy & paste from a range to a cell but come across an issue.

I am using the following code but when the value is pasted its shown in T1 T2 T3 T4 T5
My goal is to paste the values copied into the one cell at T1 as opposed to the five cells
Please advise how i can do this

Thanks

Rich (BB code):
Range("A1:A5") .Copy Range ("T1")
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
VBA Code:
Option Explicit

Sub Sample()
    Dim myArr As Variant
    myArr = Range("A1:A5").Value2
    Range("T1").Value = Join(Application.Transpose(myArr), vbLf)
End Su
 
Upvote 0
With that i get an error of Invalid Procedure.
This line of code is shown in yellow.

Rich (BB code):
Range("T1").Value = Join(Application.Transpose(myArr), vbLf)
 
Upvote 0
I didnt use that as i took the code and put it with my existing code
 
Upvote 0
Hi
could be2007
so try
VBA Code:
Sub Test()
    Dim a As Variant
    Dim x
    Dim i&
    a = Range("A1:A5")
    For i = 1 To UBound(a)
    x = IIf(x = "", a(i, 1), x & vbLf & a(i, 1))
    Range("T1") = x
   Next
End Sub
 
Upvote 0
Sorry for delay but the same.

Is there a code for cotenate that we need to use ?
 
Upvote 0
This did the trick

Rich (BB code):
Range("T1").Value = Range("A1").Value & Range("A2").Value & Range("A3").Value & Range("A4").Value & Range("A5").Value

Thanks for your time
 
Upvote 0

Forum statistics

Threads
1,216,473
Messages
6,130,838
Members
449,597
Latest member
buikhanhsang

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top