CarolineGMartin90
New Member
- Joined
- Aug 7, 2017
- Messages
- 13
Hi there!
Hoping someone can help me out! I have written up the below piece of code, which will check if the column directly above the selected Cell in Column A is empty or not, and if it is empty the macro will find the next available cell and make it the ActiveCell - thereby guiding the user to where they must input their data.
I will have that piece of code in a module which I will call, using a Private_Worksheet_SelectionChange, only when the user has selected a cell within Column A.
Both pieces of code run perfectly as Subs when I F8 through them - my problem comes when I want it to run automatically using the Private_Worksheet_SelectionChange.
My question is - does a Private_SelectionChange not recognise merely a "selection", and only a Change of value within a cell? Is there a different declaration I should be using?
Or does anyone have any other suggestions for me?
All help greatly appreciated!!
Caroline
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Call SelectionColumnA
'to be stored in a module
Sub SelectionColumnA()
Hoping someone can help me out! I have written up the below piece of code, which will check if the column directly above the selected Cell in Column A is empty or not, and if it is empty the macro will find the next available cell and make it the ActiveCell - thereby guiding the user to where they must input their data.
I will have that piece of code in a module which I will call, using a Private_Worksheet_SelectionChange, only when the user has selected a cell within Column A.
Both pieces of code run perfectly as Subs when I F8 through them - my problem comes when I want it to run automatically using the Private_Worksheet_SelectionChange.
My question is - does a Private_SelectionChange not recognise merely a "selection", and only a Change of value within a cell? Is there a different declaration I should be using?
Or does anyone have any other suggestions for me?
All help greatly appreciated!!
Caroline
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(ActiveCell, Range("A:A")) Is Nothing Then
Call SelectionColumnA
End If
End Sub
'to be stored in a module
Sub SelectionColumnA()
If Selection.Offset(-1, 0) = "" Then 'see if cell above is empty
Selection.End(xlUp).Select
ActiveCell.Offset(1, 0).Select 'select the next available cell in Column A I want user to enter data into
End If
End Sub