JackkG
01-30-2015, 05:20 PM
Hi,
I wonder what's wrong with this code. Whenever i click on the cell range the list should populate in listbox. But sometimes the SelectionChange event of worksheet works fine but sometimes it fails to work. So, I need to close the workbook and open it again in order for it to work. Can anyone explain what's wrong with this, or is there an alternative for SelectionChange? Here is the code used in worksheet.
Please help!!
-------------------
Option Explicit
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim Lastrow As Long
Application.EnableEvents = False
Lastrow = Cells(Rows.Count, 2).End(xlUp).Row
If Selection.Count = 1 Then
If Not Intersect(Target, Range("A4:A" & Lastrow)) Is Nothing Then
Author = Target.Value
authorclick
End If
End If
Application.EnableEvents = True
End Sub
I wonder what's wrong with this code. Whenever i click on the cell range the list should populate in listbox. But sometimes the SelectionChange event of worksheet works fine but sometimes it fails to work. So, I need to close the workbook and open it again in order for it to work. Can anyone explain what's wrong with this, or is there an alternative for SelectionChange? Here is the code used in worksheet.
Please help!!
-------------------
Option Explicit
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim Lastrow As Long
Application.EnableEvents = False
Lastrow = Cells(Rows.Count, 2).End(xlUp).Row
If Selection.Count = 1 Then
If Not Intersect(Target, Range("A4:A" & Lastrow)) Is Nothing Then
Author = Target.Value
authorclick
End If
End If
Application.EnableEvents = True
End Sub