Forum Discussion
Strout420
Mar 20, 2020Copper Contributor
Referencing current cell address in a formula
I would like to reference in a formula the cell address of where the cursor is currently located. As the cursor moves to the adjacent cell (up, down, backwards, forwards) this value would change. B...
Charla74
Mar 22, 2020Iron Contributor
If you're familiar with VBA you could do this with a worksheet selection change event, along the lines of the code below. This example enters the formula in cell H1 and basically starts with the base number of 18 plus whatever number is found in the active cell. Obviously, you would need to adjust the formula but in principle, this code should give you what you're looking for:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If ActiveCell > "" Then
Range("H1").Formula = "=18+" & ActiveCell.Value
Else
Range("H1").Value = 18
End If
End Sub