• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Select multiple columns and paste data in one single cell by alt+F8

Hi guys i want to run a code for the attached data pls help me.
 

Attachments

  • test file.xlsx
    16.6 KB · Views: 2
  • test file.xlsx
    16.6 KB · Views: 0
Manish

You said Multiple columns, But I think you mean Multiple cells (A5:A18)

When you mean in 1 cell, do you mean like

ANAND
AJAY
ANANT
ASHVINI
But all in one cell or like,

ANAND, AJAY, ANANT, ASHVINI
 
yes Hui... i meant multiple cells but concat is not usefull as it gives continues and useless string of text.. Let me describe what i am thinking

suppose i have selected Cells (A1:A5)
i have simple vba

Sub manish()
selection.copy
Sheets("sheet2").select
Activesheet.paste
End sub

But it gives me the same data i need all the data of Cell (A1:A5) in just one cell like in A2 of sheet2.

but in proper formating just like entering data in excel spreadsheet

Thanks
Manish
 
Try this code:
Code:
Sub Copy_Range_Paste()

Dim c As Range

MyStr = ""
For Each c In Selection
  MyStr = MyStr + c.Text + Chr(10)
Next
Set a = Application.InputBox("Select destination cell", "Select destination cell", Type:=8)
MyStr = Left(MyStr, Len(MyStr) - 1)

Range(a.Address) = MyStr

End Sub

Select Range
Alt F8
Run Copy_Range_Paste

It prompts you for a destination range
 
Back
Top