Good Day All (Please see Most recent post below)
VBA Skill: Pretty Basic
Excel type: Excel 2010
Problem:
Range("A1:A10") is where my users will enter a text structure; 1.0, 1.1, 1.2, 2.0, 2.1 etc. If the user enters a text string that includes "0" then we would like the code to activate and place a formula Offset(0, 4) from the ActiveCell, the following code is cobbled together from various posts and works to some extent:
Option Explicit
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Application.Intersect(Target, Me.Range("A1:A10")) Is Nothing Then
' At least one cell of Target is within the range A1:A10.
' Carry out some action.
If InStr(ActiveCell, "0") Then
ActiveCell.Offset(0, 4).Formula = "=SUM(1+2)"
Else
'Cell does not = 0 So Leave Code
Exit Sub
End If
End If
End Sub
This code activates if we have entered 1.0, 2.0, 3.0 etc however it only works after we return to the Cell (with Keyboard Navigation Keys), what do we need to do to make the code activate on "Enter" or when we leave the ActiveCell; i.e. User inputs 1.0 hits Enter, Tabs or Navigates using the arrow Keys Then Code Activates.
I wondered if the following would be more effcient than ActiveCell but i can't get it to work with the above code
If Not Application.Intersect(Target, Me.Range("A1:A10")) Is Nothing Then
' At least one cell of Target is within the range A1:A10.
' Carry out some action.
Any help will be gratefully received
As advised below; Apologies for delay, my work Internet is rubbish!
Test Macro Entry via VBA.xlsm
Bookmarks