Input text

  • Thread starter Thread starter ali
  • Start date Start date
A

ali

Can anyone help me please, i'm having difficulty solving this...

I want to create a macro that will allow the user to input text o
their choosing into a cell that already contains numbers,

ie I have a column full of product codes and i want to be able t
select the cells and run a macro which will bring up a box that wil
allow the user to enter the text of their choosing and when they clic
ok will insert their text before the current numbers in each of th
selected cells.

Any help would be much appreciate
 
Try something like the following:

Sub AAA()
Dim S As String
Dim Rng As Range
S = InputBox("Enter a value.")
If StrPtr(S) = 0 Then
' user hit cancel
Exit Sub
Else
For Each Rng In Selection.Cells
Rng.Value = S & Rng.Text
Next Rng
End If
End Sub

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
if I have understood your question correctly, you want
something like the following:

dim c as Range, newText as String

newText = InputBox("Please enter text", .........)

For Each c in Selection.Cells
c.value = newText & c.value
next c

Regards, Andy Keen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top