0

I want to combine text of 1000 cells of a particular column (say from A1 to A1000) to one single cell (say A1001), can anybody tell the macro for this?

Sidharth
  • 61
  • 1
  • 10
  • possible duplicate of [batch concatenate strings in excel](http://stackoverflow.com/questions/15144816/batch-concatenate-strings-in-excel) – MattClarke Jun 23 '14 at 04:24

2 Answers2

0

Try the following UDF

Public Function concat(r As Range) As String
    concat = ""
    For Each rr In r
        concat = concat & rr.Value
    Next rr
End Function

User Defined Functions (UDFs) are very easy to install and use:

  1. ALT-F11 brings up the VBE window
  2. ALT-I ALT-M opens a fresh module
  3. paste the stuff in and close the VBE window

If you save the workbook, the UDF will be saved with it. If you are using a version of Excel later then 2003, you must save the file as .xlsm rather than .xlsx

To remove the UDF:

  1. bring up the VBE window as above
  2. clear the code out
  3. close the VBE window

To use the UDF from Excel:

=concat(A1:A1000)

To learn more about macros in general, see:

http://www.mvps.org/dmcritchie/excel/getstarted.htm

and

http://msdn.microsoft.com/en-us/library/ee814735(v=office.14).aspx

and

http://www.cpearson.com/excel/WritingFunctionsInVBA.aspx

for specifics on UDFs

Macros must be enabled for this to work!

Community
  • 1
  • 1
Gary's Student
  • 95,722
  • 10
  • 59
  • 99
-1
=concatenate(A1:A1000)

As the formula in A1001

Steve Barnes
  • 27,618
  • 6
  • 63
  • 73