ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Adding strings using macros (https://www.excelbanter.com/excel-worksheet-functions/214314-adding-strings-using-macros.html)

ultrarev

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.

Mike H

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.


Don Guillett

Adding strings using macros
 
sub AddX()
for i=1 to cells(rows.count,"a").end(xlup).row
cells(i,"a").value=cells(i,"a")&"-"& i
next i
end sub
--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"ultrarev" wrote in message
...
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.



Luke M

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.


ultrarev

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.


ultrarev

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.



All times are GMT +1. The time now is 05:41 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com