how we can run macro after a written text in a column

R

rich_jonathan

we have some written text in column, we want to add a macro that will add
some other text to that column, how we can do this ???
 
S

Stefi

You don't mention the source of text to add. If it's a constant string, this
macro adds it to cells in column A:

Sub addtext()
Dim Acell As Range
Addedtext = "texttoadd"
NoOfUsedCells = Range("A" & Rows.Count).End(xlUp).Row
For Each Acell In Range("A1:A" & NoOfUsedCells)
Acell.Value = Acell.Value & Addedtext
Next Acell
End Sub

Regards,
Stefi


„rich_jonathan†ezt írta:
 
G

Gord Dibben

Sub Add_Text()
Dim cell As Range
Dim moretext As String
Dim thisrng As Range
On Error GoTo endit
whichside = InputBox("Left = 1 or Right =2")
Set thisrng = Range(ActiveCell.Address & "," & Selection.Address) _
.SpecialCells(xlCellTypeConstants, xlTextValues)
moretext = InputBox("Enter your Text")
If whichside = 1 Then
For Each cell In thisrng
cell.Value = moretext & cell.Value
Next
Else
For Each cell In thisrng
cell.Value = cell.Value & moretext
Next
End If
Exit Sub
endit:
MsgBox "only formulas in range"
End Sub


Gord Dibben MS Excel MVP
 
Top