How to edit multiple cells at once?

mobby123

New Member
Joined
Jul 17, 2015
Messages
3
So I've got a pretty large spreadsheet and I need to add "AAA" to the end of every cell in a section of column A. So to take a completely random example, instead of "Pigs" it would be "Pigs AAA", and the one below that would be "Sheep AAA" and so on? Or do I have to manually type the AAA everywhere it's needed?

Sorry if it's explained badly but thanks in advance!
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Welcome to the board.

A macro would be easiest way to do this; do you require it for every value in column A or a specific range (e.g. ignore row 1 as it contains the header). I can write some code to do this, you can then search online on how to write and run a macro by copying the code, then running it.

With assumption header is in row 1 and you require it for every row, except row 1 in column A, try:
Code:
Sub AddPostFix()

Dim var()   As Variant
Dim x       As Long
Const str1  As String = " AAA"

x = Range("A" & Rows.Count).End(xlUp).Row

var = Range("A2").Resize(x - 1).Value

For x = LBound(var, 1) To UBound(var, 1)
    var(x, 1) = var(x, 1) & str1
Next x

Range("A2").Resize(x - 1).Value = var

Erase var

End Sub
 
Upvote 0
Thanks for the reply Jack!

The values I'd be looking for would be 2-189, I'm sure I could figure out how to do the rest of the column if you did a quick edit on the above macro and inserted the relevant figures.
 
Upvote 0
The macro runs from row 2 to the last used row in column A and is reasonably fast - faster than manually making the same number of edits. To change to 2 to 189, I've commented out the line that determines the last used row and added in blue, for 189:
Rich (BB code):
Sub AddPostFix()

Dim var()   As Variant
Dim x       As Long
Const str1  As String = " AAA"

'x = Range("A" & Rows.Count).End(xlUp).Row
x = 189

var = Range("A2").Resize(x - 1).Value

For x = LBound(var, 1) To UBound(var, 1)
    var(x, 1) = var(x, 1) & str1
Next x

Range("A2").Resize(x - 1).Value = var

Erase var

End Sub
 
Upvote 0
You're welcome, glad I could help and thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,223,912
Messages
6,175,340
Members
452,638
Latest member
Oluwabukunmi

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