Reputation: 191
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.
Upvotes: 5
Views: 31796
Reputation: 1475
A more flexible approach is to use custom format for such arbitrary suffixes. For example,
ActiveCell.NumberFormat = "#,##0 T;-#,##0 T"
will put the T as you want for 750 T without the overhead of re-running macros when the number 750 changes. You can copy, paste, sort, and perform the usual operations on such cell values without affecting the T suffix.
Upvotes: 5
Reputation: 2355
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.
Upvotes: 9