Modify each cell in selection

  • Thread starter Thread starter Clayman
  • Start date Start date
C

Clayman

I need to modify each cell in a selection, adding a string constant to the
text in each cell. ie:
- a1="A"
- b1="B"
- c1="0"
- d1="E"

and I need to add "(DR1)" to each of these. I've tried researching "For
Each" 'cuz I know that is what I need, but I'm not certain exactly where to
go from there. My thoughts (reserved words may be ignored):

For Each cell In Selection
holder=cell.value
holder=holder & "(DR1)"
cell.value=holder
Next

Will this do it?
 
Your code should work but you could shorten it up a bit...

dim Cell as range

for each cell in Selection
cell.value = cell.value & "(DR)"
nect cell
 
Typo... nect should be next...

dim Cell as range

for each cell in Selection
cell.value = cell.value & "(DR)"
next cell
 
Sanctuary much, Jim!
This worked quite well. I actually learned quite a bit during this little
endeavor - mostly how the "Range" type works. I had no idea it would be that
simple!
 
Back
Top