ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   How can I edit cell contents with a macro in Excel? (https://www.excelbanter.com/excel-discussion-misc-queries/18826-how-can-i-edit-cell-contents-macro-excel.html)

Mind the gaps!

How can I edit cell contents with a macro in Excel?
 
I'm trying to creat an Excel macro that edits cell data, remembering the
edits, not just the resulting value or formula. If, for example, I want to
delete all but the last three characters of a cell value, and I record a
macro, editing the cell produces a line like: ActiveCell.FormulaR1C1 = "745".
But I don't want the specific value. I want the process.

I'm essentially asking for RIGHT(R1C1,3), but I can't use that formula in
the macro because it would be a circular reference. What am I missing?

Rowan

If you use the Value property you can just replace the old value with the new
one e.g.

ActiveCell.Value = Right(ActiveCell.Value, 3)

Regards
Rowan

"Mind the gaps!" wrote:

I'm trying to creat an Excel macro that edits cell data, remembering the
edits, not just the resulting value or formula. If, for example, I want to
delete all but the last three characters of a cell value, and I record a
macro, editing the cell produces a line like: ActiveCell.FormulaR1C1 = "745".
But I don't want the specific value. I want the process.

I'm essentially asking for RIGHT(R1C1,3), but I can't use that formula in
the macro because it would be a circular reference. What am I missing?


NotAnExpert

I knew this had to be easy. That's why I could never find it in the books.
Rowan, Thank you very much!

NotAnExpert, aka MindTheGaps!

"Rowan" wrote:

If you use the Value property you can just replace the old value with the new
one e.g.

ActiveCell.Value = Right(ActiveCell.Value, 3)

Regards
Rowan



All times are GMT +1. The time now is 12:41 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com