PDA

View Full Version : [SOLVED:] Preceed or Append data to the selected cell(s)



ilyaskazi
03-25-2005, 07:42 AM
macro required for adding data in cell for the selected ranges.

For Example:
1) Preceed = "NEW" for the foll cells..

YORK
DELHI
BOMBAY
CAR

Output:

NEWYORK
NEWDELHI
NEWBOMBAY
NEWCAR

2) Append = "PHONE" for the foll cells..

MOBILE
CELL
SMART
SATELITE

Output:

MOBILEPHONE
CELLPHONE
SMARTPHONE
SATELITEPHONE

While executing it should ask user containing 2 txtboxes in userform for preceeding and appending data for the selected range to manipulate.

Jacob Hilderbrand
03-25-2005, 09:43 AM
Let's say you have a UserForm with TextBox1 for Preceed and TextBox2 for Post then try this.


Option Explicit

Sub Macro1
Dim MyRange As Range
Dim Cel As Range
Set MyRange = Range("A1:B10")
For Each Cel In MyRange
Cel.Value = Me.TextBox1.Text & Cel.Text & Me.TextBox2.Text
Next
End Sub