How to create Macro that copies the updated content (text) of the same cell each time the Macro is activated (copying the current content).
How to create Macro that copies the updated content (text) of the same cell each time the Macro is activated (copying the current content).
The code below will do what you want. Paste it into a standard code module. You can hitch it to a button, create a keyboard shortcut to run it, run it from the Macros button on the Developer tab, or run it manually from the VB Editor screen using one of the methods acceptable there. Modify the constants SourceCell and TargetCell to fit your requirements.
Sub CopyCellContent()
Const SourceCell As String = "A1"
Const TargetCell As String = "C1"
Range(TargetCell).Value = Range(SourceCell).Value
End Sub
The code lays bare the deficiencies of your question, however. For example, it copies from and pastes to the active sheet which may or may not be in the workbook that contains the code. There is some probability that you want the SourceCell to be on another sheet and the TargetCell not on the same sheet.
Note that the code expressly only copies SourceCell's value. That makes sense if you intend to format that cell. However, if you wish to copy the cell formats from the SourceCell along with the cell value a different method of copy/pasting should be employed, like,
Range(TargetCell).Copy Destination:=Range(Targetcell)
The code always pastes to the same cell. That isn't very likely your intention. However, you asked how to write such code and here is the answer. Should you face problems adjusting the code please ask your question in a new threat.