ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Can't select another cell after running a macro.... (https://www.excelbanter.com/excel-programming/277832-cant-select-another-cell-after-running-macro.html)

John[_49_]

Can't select another cell after running a macro....
 
The below code works by highlighting a row based upon a selection from
a drop down box. But then I am no longer able to use my mouse to
select another cell. Range("A5:L5") stay selected. I am thinking it
should be a quick fix but I cannot figure it out. Thanks for any help
you can lend to this matter. The code was courteous of Tom Ogilvy



Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Range("N5") = 3 Then
Range("A5:L5").Select
With Selection.Interior
.ColorIndex = 6
.Pattern = xlSolid
End With
Else
Range("A5:L5").Select
Selection.Interior.ColorIndex = xlNone
End If
End Sub

Ken Macksey

Can't select another cell after running a macro....
 
Hi

Try putting the code in the

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As
Excel.Range)

sub instead of the

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target
As Excel.Range)

sub.


HTH

Ken



"John" wrote in message
om...
The below code works by highlighting a row based upon a selection from
a drop down box. But then I am no longer able to use my mouse to
select another cell. Range("A5:L5") stay selected. I am thinking it
should be a quick fix but I cannot figure it out. Thanks for any help
you can lend to this matter. The code was courteous of Tom Ogilvy



Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Range("N5") = 3 Then
Range("A5:L5").Select
With Selection.Interior
.ColorIndex = 6
.Pattern = xlSolid
End With
Else
Range("A5:L5").Select
Selection.Interior.ColorIndex = xlNone
End If
End Sub




---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.512 / Virus Database: 309 - Release Date: 19/08/2003




All times are GMT +1. The time now is 01:00 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com