Forum Discussion
NRASA0743
Jul 20, 2022Copper Contributor
Inserting formula in a cell
Hello, I'm trying to insert a RIGHT formula in one column but my macros goes into break mode. Wanted the variable cell to be whatever cell I selected with the mouse before running the macro. Any Adv...
- Jul 21, 2022
Hi NRASA0743
yes, that's because this was the formula that you wanted to put in the cell based on your original question.
Sorry, now I think I understand: You want only the last 4 characters of whatever is currently in the cell? This should do it:
Selection.Value = Right(Selection.Value, 4)
Please note that this works only for single cells, not for a selection of multiple cells.
Martin_Weiss
Jul 20, 2022Bronze Contributor
Hi NRASA0743
you do not need a cell variable. And you need to set the RIGHT-formula in quotation marks.
This should do it:
Selection.FormulaR1C1 = "=RIGHT(""****"",4)"
- NRASA0743Jul 20, 2022Copper Contributor
Martin_Weiss the 4 desired characters do not appear.
- Martin_WeissJul 20, 2022Bronze Contributor
- NRASA0743Jul 20, 2022Copper Contributor
Martin_Weiss macro only shows the "*****" but not the last 4 characters. No error or break mode.