ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   how we can run macro after a written text in a column (https://www.excelbanter.com/excel-discussion-misc-queries/180864-how-we-can-run-macro-after-written-text-column.html)

rich_jonathan

how we can run macro after a written text in a column
 
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 ???

Stefi

how we can run macro after a written text in a column
 
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:

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 ???


Gord Dibben

how we can run macro after a written text in a column
 
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

On Thu, 20 Mar 2008 23:46:00 -0700, rich_jonathan
wrote:

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 ???




All times are GMT +1. The time now is 03:02 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com