Selection Change problem

Misca

Well-known Member
Joined
Aug 12, 2009
Messages
1,749
Office Version
  1. 365
Platform
  1. Windows
I have the following macro in my workbook.

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Target, Range("AV10:AZ10")) Is Nothing Then
    If IsNumeric(Target) Then
        Call ShowRanges
    End If
End If

If Not Intersect(Target, Range("AU1")) Is Nothing And Target.Value <> "" Then
Call GetName
End If

End Sub
The macros that are called from this one should be working just fine but still the macro seems to crash every now and then. And when it crashes and I select Debug & just reset the error and it works again.

I was thinking the problem should be with this one (this is the one that always shows up yellow on the Debug mode) but I can't think of any other reason but having two different Selections to follow.

Does anybody know what might be causing the problem & how to fix it? I seem to be running out of ideas myself.
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Hi, I found the problem shows when you select multiple cells, so I added an extra first line.(Target .count = 1)
Seems to work.!!
Code:
Private [COLOR=navy]Sub[/COLOR] Worksheet_SelectionChange(ByVal Target [COLOR=navy]As[/COLOR] Range)
[COLOR=navy]If[/COLOR] Target.Count = 1 [COLOR=navy]Then[/COLOR]
[COLOR=navy]If[/COLOR] Not Intersect(Target, Range("AV10:AZ10")) [COLOR=navy]Is[/COLOR] Nothing [COLOR=navy]Then[/COLOR]
    [COLOR=navy]If[/COLOR] IsNumeric(Target) [COLOR=navy]Then[/COLOR]
        Call Showranges
    [COLOR=navy]End[/COLOR] If
[COLOR=navy]End[/COLOR] If
[COLOR=navy]If[/COLOR] Not Intersect(Target, Range("AU1")) [COLOR=navy]Is[/COLOR] Nothing And Target.Value <> "" [COLOR=navy]Then[/COLOR]
Call getname
[COLOR=navy]End[/COLOR] If
[COLOR=navy]End[/COLOR] [COLOR=navy]If[/COLOR]
[COLOR=navy]End[/COLOR] [COLOR=navy]Sub[/COLOR]
Regards Mick
 
Upvote 0

Forum statistics

Threads
1,214,918
Messages
6,122,257
Members
449,075
Latest member
staticfluids

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top