Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
I need to run the script for concantenating the cells.
For eg: If I have 10 serial numbers in A1:A10, these numbers should accompany with the ",". the result should come as 1,2,3,4,5,6,7,8,9,10 Often working with the formula is difficult, so I have planned to run macros. Could any one pls guide me with the script. |
#2
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
Try this :
in cell: =MyConcatenate(A1:A10) or any range Function MyConcatenate(ByRef myrng As Range) mystr = "" For Each Cell In myrng mystr = mystr + Str(Cell.Value) & "," Next MyConcatenate = Left(mystr, Len(mystr) - 1) End Function HTH "Igneshwara reddy" wrote: I need to run the script for concantenating the cells. For eg: If I have 10 serial numbers in A1:A10, these numbers should accompany with the ",". the result should come as 1,2,3,4,5,6,7,8,9,10 Often working with the formula is difficult, so I have planned to run macros. Could any one pls guide me with the script. |
#3
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
Have a look at the =CONCATENATE function
or =A1&","&A2&","&... you get the idea cheers Simon Blog: www.smurfonspreadsheets.net Website: www.codematic.net Excel development, support and training "Igneshwara reddy" wrote in message ... I need to run the script for concantenating the cells. For eg: If I have 10 serial numbers in A1:A10, these numbers should accompany with the ",". the result should come as 1,2,3,4,5,6,7,8,9,10 Often working with the formula is difficult, so I have planned to run macros. Could any one pls guide me with the script. |
#4
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
Hi, thanks for the advise.
But I am unable to run that script, see below which I have show you how my script is showing. Regards, Sub Macro2() ' ' Macro2 Macro ' Macro recorded 3/7/2007 by ir230005 ' ' =MyConcatenate(A1:A10) ' Function MyConcatenate(ByRef myrng As Range) ' mystr = "" ' For Each Cell In myrng ' mystr = mystr + Str(Cell.Value) & "," ' Next ' MyConcatenate = Left(mystr, Len(mystr) - 1) End Sub "Toppers" wrote: Try this : in cell: =MyConcatenate(A1:A10) or any range Function MyConcatenate(ByRef myrng As Range) mystr = "" For Each Cell In myrng mystr = mystr + Str(Cell.Value) & "," Next MyConcatenate = Left(mystr, Len(mystr) - 1) End Function HTH "Igneshwara reddy" wrote: I need to run the script for concantenating the cells. For eg: If I have 10 serial numbers in A1:A10, these numbers should accompany with the ",". the result should come as 1,2,3,4,5,6,7,8,9,10 Often working with the formula is difficult, so I have planned to run macros. Could any one pls guide me with the script. |
#5
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
You put =Myconcatenate(A1;A10) in the cell e.g B1 ,where you want the result
to appear (just like any Excel function). Simply copy/paste the code I posted into a VBE module .. it's a function not a subroutine. HTH "Igneshwara reddy" wrote: Hi, thanks for the advise. But I am unable to run that script, see below which I have show you how my script is showing. Regards, Sub Macro2() ' ' Macro2 Macro ' Macro recorded 3/7/2007 by ir230005 ' ' =MyConcatenate(A1:A10) ' Function MyConcatenate(ByRef myrng As Range) ' mystr = "" ' For Each Cell In myrng ' mystr = mystr + Str(Cell.Value) & "," ' Next ' MyConcatenate = Left(mystr, Len(mystr) - 1) End Sub "Toppers" wrote: Try this : in cell: =MyConcatenate(A1:A10) or any range Function MyConcatenate(ByRef myrng As Range) mystr = "" For Each Cell In myrng mystr = mystr + Str(Cell.Value) & "," Next MyConcatenate = Left(mystr, Len(mystr) - 1) End Function HTH "Igneshwara reddy" wrote: I need to run the script for concantenating the cells. For eg: If I have 10 serial numbers in A1:A10, these numbers should accompany with the ",". the result should come as 1,2,3,4,5,6,7,8,9,10 Often working with the formula is difficult, so I have planned to run macros. Could any one pls guide me with the script. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
I need some VB script please | Excel Discussion (Misc queries) | |||
VB Script | Excel Worksheet Functions | |||
VB script help - please!! | Excel Discussion (Misc queries) | |||
VBA script help..Please !!!! | Excel Discussion (Misc queries) | |||
VB script help..please !! | Excel Worksheet Functions |