Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 68
Default help with the VB script

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   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 4,339
Default help with the VB script

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   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 30
Default help with the VB script

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   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 68
Default help with the VB script

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   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 4,339
Default help with the VB script

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
I need some VB script please rlee1999 Excel Discussion (Misc queries) 2 October 25th 06 05:46 PM
VB Script Krista Excel Worksheet Functions 4 May 20th 06 03:12 PM
VB script help - please!! Anthony Excel Discussion (Misc queries) 1 July 13th 05 01:19 AM
VBA script help..Please !!!! Anthony Excel Discussion (Misc queries) 6 June 6th 05 01:40 PM
VB script help..please !! Anthony Excel Worksheet Functions 2 June 5th 05 03:26 PM


All times are GMT +1. The time now is 10:33 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"