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
[TABLE="width: 271"]
<colgroup><col><col></colgroup><tbody>[TR]
[TD]ABI117[/TD]
[TD]ABI117A[/TD]
[/TR]
[TR]
[TD]ABI125[/TD]
[TD]ABI117R[/TD]
[/TR]
[TR]
[TD]ABI118[/TD]
[TD]ABI117S[/TD]
[/TR]
[TR]
[TD]ABI105[/TD]
[TD]ABI125A[/TD]
[/TR]
[TR]
[TD]ABI100[/TD]
[TD]ABI125R[/TD]
[/TR]
[TR]
[TD]ABI114...[/TD]
[TD]ABI125S...
[/TD]
[/TR]
</tbody>[/TABLE]

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

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
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,223,911
Messages
6,175,326
Members
452,635
Latest member
laura12345

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