Hello,
I am trying to update when users change one or group of cells within a range when there is a space to replace with an underscore. It is working, however with a group a cells, perhaps like copy or control enter, the values only update after you click on each cell. Works okay when one cell is clicked.
Example if select at range of Cells an input "Location 1" then expected result would be Location_1.
Private Sub Worksheet_SelectionChange(ByVal Target as Range)
Dim loc as Range, res as string
Set loc = Range("A1:A20")
If Not Application.Intersect(loc, Range(Target.Address)) _
Is Nothing Then
Application.EnableEvents = False
For Each loc in Target
res = (Replace(loc.Value, Space(1), "_")
loc = res
Next loc
Application.EnableEvents - True
End If
End Sub
I am trying to update when users change one or group of cells within a range when there is a space to replace with an underscore. It is working, however with a group a cells, perhaps like copy or control enter, the values only update after you click on each cell. Works okay when one cell is clicked.
Example if select at range of Cells an input "Location 1" then expected result would be Location_1.
Private Sub Worksheet_SelectionChange(ByVal Target as Range)
Dim loc as Range, res as string
Set loc = Range("A1:A20")
If Not Application.Intersect(loc, Range(Target.Address)) _
Is Nothing Then
Application.EnableEvents = False
For Each loc in Target
res = (Replace(loc.Value, Space(1), "_")
loc = res
Next loc
Application.EnableEvents - True
End If
End Sub