Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3
Default Adding strings using macros

010630412
010630412
010630412
010630412
010630412
010630412
010630512
010630512
010630512
010630512
010630512

That is my line how can I make it look like this :

010630412-1
010630412-2
010630412-3
010630412-4
010630412-5
010630412-6
010630512-7
010630512-8
010630512-9

basically adding dash 1,2,3 and so fourth to every line without changing the
first set of numbers? Is this possible please explain.
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,501
Default Adding strings using macros

Hi,

I've assumed this data are in column A. Right click your sheet tab, view
code and paste this in and run it.

Sub merge()
x = 1
lastrow = Cells(Rows.Count, "A").End(xlUp).Row
Set MyRange = Range("A1:A" & lastrow)
For Each c In MyRange
c.Value = c.Value & "-" & x
x = x + 1
Next
End Sub

Mike

"ultrarev" wrote:

010630412
010630412
010630412
010630412
010630412
010630412
010630512
010630512
010630512
010630512
010630512

That is my line how can I make it look like this :

010630412-1
010630412-2
010630412-3
010630412-4
010630412-5
010630412-6
010630512-7
010630512-8
010630512-9

basically adding dash 1,2,3 and so fourth to every line without changing the
first set of numbers? Is this possible please explain.

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,722
Default Adding strings using macros

If you prefer formula, in column B
=A1&"-"&ROW(A1)
--
Best Regards,

Luke M
*Remember to click "yes" if this post helped you!*


"ultrarev" wrote:

010630412
010630412
010630412
010630412
010630412
010630412
010630512
010630512
010630512
010630512
010630512

That is my line how can I make it look like this :

010630412-1
010630412-2
010630412-3
010630412-4
010630412-5
010630412-6
010630512-7
010630512-8
010630512-9

basically adding dash 1,2,3 and so fourth to every line without changing the
first set of numbers? Is this possible please explain.

  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3
Default Adding strings using macros

Thank you sooooooo much!!!!!!

"Mike H" wrote:

Hi,

I've assumed this data are in column A. Right click your sheet tab, view
code and paste this in and run it.

Sub merge()
x = 1
lastrow = Cells(Rows.Count, "A").End(xlUp).Row
Set MyRange = Range("A1:A" & lastrow)
For Each c In MyRange
c.Value = c.Value & "-" & x
x = x + 1
Next
End Sub

Mike

"ultrarev" wrote:

010630412
010630412
010630412
010630412
010630412
010630412
010630512
010630512
010630512
010630512
010630512

That is my line how can I make it look like this :

010630412-1
010630412-2
010630412-3
010630412-4
010630412-5
010630412-6
010630512-7
010630512-8
010630512-9

basically adding dash 1,2,3 and so fourth to every line without changing the
first set of numbers? Is this possible please explain.



  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3
Default Adding strings using macros

Is it possible to insert new rows, example:

21-416B,C,P,R

and have it look like this:

21-416B
21-416C
21-416P
21-416R

I would greatly appreaciate any help!!

"Mike H" wrote:

Hi,

I've assumed this data are in column A. Right click your sheet tab, view
code and paste this in and run it.

Sub merge()
x = 1
lastrow = Cells(Rows.Count, "A").End(xlUp).Row
Set MyRange = Range("A1:A" & lastrow)
For Each c In MyRange
c.Value = c.Value & "-" & x
x = x + 1
Next
End Sub

Mike

"ultrarev" wrote:

010630412
010630412
010630412
010630412
010630412
010630412
010630512
010630512
010630512
010630512
010630512

That is my line how can I make it look like this :

010630412-1
010630412-2
010630412-3
010630412-4
010630412-5
010630412-6
010630512-7
010630512-8
010630512-9

basically adding dash 1,2,3 and so fourth to every line without changing the
first set of numbers? Is this possible please explain.

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
adding column to workbook with macros Tim[_6_] Excel Discussion (Misc queries) 3 November 6th 07 05:49 PM
Adding macros to toolbars Elsa Excel Discussion (Misc queries) 1 January 30th 07 09:38 PM
How to find number of pairs of strings from list of strings? greg_overholt Excel Worksheet Functions 5 January 27th 06 10:42 PM
ex.=($B$4+C4) in macros for row why adding rest Sherry Excel Worksheet Functions 4 December 30th 05 12:19 AM
ex.=($B$4+C4) in macros for row why adding rest Sherry Excel Worksheet Functions 0 December 29th 05 06:29 PM


All times are GMT +1. The time now is 01:14 AM.

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

About Us

"It's about Microsoft Excel"