Adding a prefix and or suffix

Sipsoo

New Member
Joined
Jul 12, 2006
Messages
19
Hi Group,

I want to create a macro that will inset a ',' at the end of a populated cells i.e.

range A1 to A30

C88085','
A83016','
F86008','
M91021','
P81004','
F86651','
A82008','
A83075','

The cells will be populated manually then I would like to run the macro that will and the suffix to the populated cells.

Is this possible

Thanks in advance


Ken
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Based on a macro I wrote to convert policy numbers into the correct format for my SQL editor...

Code:
Sub replacetext()
Dim Myvalue As Variant
Dim n As Integer


Application.ScreenUpdating = False

With ActiveSheet

n = 1
Do While Len(.Cells(n, 1)) > 0

'Insert  comma and space to each policy number
Myvalue = Cells(n, 1)
Cells(n, 1).Value Myvalue & ", "

 n = n + 1
 Loop
 
Upvote 0
Hi, Ken,

try this
Code:
Option Explicit

Sub test()
Dim rng As Range
Dim arr As Variant
Dim LR As Long
Dim i As Long
Dim j As Integer

    With ActiveSheet
    LR = .Cells(Rows.Count, 1).End(xlUp).Row
    Set rng = .Range("A1:A" & LR)
    End With

arr = rng

    For i = 1 To rng.Rows.Count
    arr(i, 1) = arr(i, 1) & ","
    Next i

rng = arr
Erase arr

End Sub

for more info about this technique see http://puremis.net/excel/code/053.shtml

kind regards,
Erik
 
Upvote 0

Forum statistics

Threads
1,214,591
Messages
6,120,424
Members
448,961
Latest member
nzskater

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