Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding text to a cell using VBA WITHOUT deleting what was already in the cell

Tags:

excel

vba

I am trying to change what is in a cell after a macro populates it with data. For instance, my macro will place 750 in the cell. I need to then place a "T" in the cell, after the 750, without deleting the 750. The 750 will change each time I use the macro, so I can't just use ActiveCell.FormulaR1C1 = "750 T"

It will always be a number with a "T" added, although its fine if it's formatted as text.

like image 345
bdkong Avatar asked Dec 10 '22 22:12

bdkong


1 Answers

You want to keep what's there and add a T, so here is how:

ActiveCell.Value = ActiveCell.Value & " T"

You can change ActiveCell to whatever you want.

Completely plagiarized from @padawan0007, although the answer was obvious.

Also I have to ask if you are using ActiveCell.FormulaR1C1 for a particular reason? You should use .Value instead if you're not inserting an actual formula.

like image 129
David G Avatar answered May 08 '23 09:05

David G