I am wondering if anyone knows a way to implement the following behavior in Excel.
More generally:
My use case does not require entering formulas, the user will only ever enter need to fixed values. But if such a feature did exist and did allow for formulas, I'd expect formulas to be properly relative. I.e., if you enter "=A3+1" in A4, the formula appears as "=B5+1" in B6.
Not interested in (and will not accept) any workarounds that involve setting up something like separate input/output cells, or if user has to do anything other than enter a value into a cell in a normal way. A macro solution is undesirable, but may be acceptable.
Googled, found nothing relevant. (It's hard because I'm being swamped in results on how to do string concatenation.)
A3
was changed to 1
.C7
was changed to 2
..xlsm
or .xlsb
file. Apply the same in your desired workbook.Sheet Module, e.g. Sheet1
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
PopulateWithChangedValue Target, "A3,B5,C7,D9"
End Sub
Sub PopulateWithChangedValue( _
ByVal Target As Range, _
ByVal RangeAddress As String)
Const PROC_TITLE As String = "Populate With Same Value"
On Error GoTo ClearError
Dim srg As Range: Set srg = Target.Worksheet.Range(RangeAddress)
Dim trg As Range: Set trg = Intersect(srg, Target)
If trg Is Nothing Then Exit Sub
Application.EnableEvents = False
srg.Value = trg.Cells(1).Value
ProcExit:
On Error Resume Next
Application.EnableEvents = True
On Error GoTo 0
Exit Sub
ClearError:
MsgBox "Run-time error '" & Err.Number & "':" & vbLf & vbLf _
& Err.Description, vbCritical, PROC_TITLE
Resume ProcExit
End Sub