Excel formula question

tuathome

New Member
Joined
Apr 18, 2018
Messages
3
Hi,
My first post in this forum. Any help is appreciated. Thanks.

What I'm to achieve in ColumnB based on ColumnA: For each ID in ColumnA, create 3 IDs with letters A, R, S appended to the ID.
ColumnA ColumnB
ABI117ABI117A
ABI125ABI117R
ABI118ABI117S
ABI105ABI125A
ABI100ABI125R
ABI114...ABI125S...

<colgroup><col><col></colgroup><tbody>
</tbody>

What should my formula for ColumnB be?
(I am currently using =INDIRECT("A"&2)&"A" and =INDIRECT("A"&2)&"R" and =INDIRECT("A"&2)&"S" ) But I need a way to copy this formula and paste it for the rest of the column.

Any ideas?
-Em
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Would VBA be OK

Code:
Sub idnums()Dim lr As Long
Dim nr As Long
lr = Cells(Rows.Count, "A").End(xlUp).Row 'find last row of column A
nr = Cells(Rows.Count, "B").End(xlUp).Row + 1
If nr < 2 Then nr = 2 'assums you want to start in row 2 column headers in row 1 and column is blank
For x = 2 To lr
    
    Cells(nr, 2) = Cells(x, "A") & "A"
    nr = Cells(Rows.Count, "B").End(xlUp).Row + 1
    Cells(nr, 2) = Cells(x, "A") & "B"
    nr = Cells(Rows.Count, "B").End(xlUp).Row + 1
    Cells(nr, 2) = Cells(x, "A") & "S"
    nr = Cells(Rows.Count, "B").End(xlUp).Row + 1
Next x

End Sub
 
Upvote 0
Hi Scott,
Thanks for your suggestion. I haven't worked with VBA so is this all I need to embed into my Excel spreadsheet?
Em

Would VBA be OK

Code:
Sub idnums()Dim lr As Long
Dim nr As Long
lr = Cells(Rows.Count, "A").End(xlUp).Row 'find last row of column A
nr = Cells(Rows.Count, "B").End(xlUp).Row + 1
If nr < 2 Then nr = 2 'assums you want to start in row 2 column headers in row 1 and column is blank
For x = 2 To lr
    
    Cells(nr, 2) = Cells(x, "A") & "A"
    nr = Cells(Rows.Count, "B").End(xlUp).Row + 1
    Cells(nr, 2) = Cells(x, "A") & "B"
    nr = Cells(Rows.Count, "B").End(xlUp).Row + 1
    Cells(nr, 2) = Cells(x, "A") & "S"
    nr = Cells(Rows.Count, "B").End(xlUp).Row + 1
Next x

End Sub
 
Upvote 0
in Excel open the VBA editor ALT-F11 or from the Developer tab select Visual Basic
In he VBA editor create a new module from the menu Insert-> Module
Past the code into the module
note the forum combined lines

Code:
Sub idnums()Dim lr As Long
should be
Code:
Sub idnums()
Dim lr As Long


To run the macro you can create a button that will run it or in Excel use ALT-F8 and select the macro and click run
 
Upvote 0
YAY Scott! I got it to work.
Thank you so much for your help. It saves my work day!!


in Excel open the VBA editor ALT-F11 or from the Developer tab select Visual Basic
In he VBA editor create a new module from the menu Insert-> Module
Past the code into the module
note the forum combined lines

Code:
Sub idnums()Dim lr As Long
should be
Code:
Sub idnums()
Dim lr As Long


To run the macro you can create a button that will run it or in Excel use ALT-F8 and select the macro and click run
 
Upvote 0

Forum statistics

Threads
1,213,489
Messages
6,113,949
Members
448,534
Latest member
benefuexx

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top