Add a constant value to a range of cells during a copy macro

  • Thread starter Thread starter Kurt Barr
  • Start date Start date
K

Kurt Barr

Ok,

I've got one worksheet that I'm trying to convert to a new worksheet, and
one of the values that I'm converting is changing from a 3 character code to
a 6 character code. The 3 new characters ("F00") that I'm adding are the same
for every value that I'm coverting in that column, and they are added to the
front of the string.

Is there a way to add the new characters as I paste the value during the
conversion, or do I need to try and program a loop to do this for me?
 
After your copy, select the cells you want to change and:

Sub updatee()
For Each r In Selection
r.Value = "FOO" & r.Value
Next
End Sub
 
It would be really helpful to see the code you have. I can assume you want
something like this below. This code assumes all the cells you want changed
are in Col. A.

Sub CopyCells()

Dim i As Long
Const c As String = "F00"

For i = 1 To 10
Sheets("Sheet2").Cells(i, 1) = c & Sheets("Sheet1").Cells(i, 1)
Next i

End Sub

Hope this helps!
 

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