Select ALL cells problem and advice please

jhg1226

New Member
Joined
Jul 31, 2010
Messages
6
Hi, and thanks for taking the time to view this post.

I am running the following code to create 20 or thirty message boxes that activate when particular cells are clicked. Essentially, I need to provide the user information related to specific cell entries. My problem is when the user selects the upper left cell that selects all cell on the worksheet, I get a "Run-time error '6': Overflow error".

How can I get around this problem? Second question is: Am I going about this the right way? Keep in mind I am a novice and do not want to make this too complicated.

Option Explicit


Private Sub Worksheet_SelectionChange(ByVal target As Range)
'Service


Application.ScreenUpdating = False

If Selection.Count = 1 Then
If Not Intersect(target, Range("A19")) Is Nothing Then
MsgBox "Service prior to 9-7-80 - At least 1 AND more message" & vbCrLf & _

"90 days service." & vbCrLf & vbCrLf & _

"Service after More of this message AND 24 months active service " & _

"OR served full period to which he/she was called” & vbCrLf & vbCrLf & _
"Exceptions would go here." & vbCrLf & vbCrLf & _
"Check Chart for appropriate dates." & vbCrLf & vbCrLf & _
"***Claims should be reviewed." & vbCrLf & vbCrLf & _

"If doesn't have qualifying service more of message." & vbCrLf & vbCrLf & _

"No further development is needed.***"

End If

'Presumptive Entitlement
If Selection.Count = 1 Then
If Not Intersect(target, Range("A17")) Is Nothing Then
MsgBox "More of the message " & vbCrLf & _

" Part of message:” & vbCrLf & vbCrLf & _
" Age 65 or older, OR " & vbCrLf & vbCrLf & _
" A patient in a nursing home, OR" & vbCrLf & vbCrLf & _
" Disabled with more of the message. " & vbCrLf & vbCrLf & _

" More of message. "
End If

End If
End If
End Sub



Thanks!!!
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
75,362
Office Version
365
Platform
Windows
Which line of code causes the error?

Does changing Selection.Count to Target.Count make any difference?

PS Is this all the code?
 

jhg1226

New Member
Joined
Jul 31, 2010
Messages
6
You are correct in that the line causing the problem is Selection.count, but changing it to target.count does not help.

Yes, this is all the code. Thanks for responding!
 

shg

MrExcel MVP
Joined
May 7, 2008
Messages
21,712
Office Version
2010
Platform
Windows
Change Selection.Count to Selection.CountLarge
 

jhg1226

New Member
Joined
Jul 31, 2010
Messages
6
THANK YOU!!! Works like a charm and so easy to fix.

I really appreciate your help!
 

shg

MrExcel MVP
Joined
May 7, 2008
Messages
21,712
Office Version
2010
Platform
Windows
You're welcome.
 

Forum statistics

Threads
1,081,543
Messages
5,359,431
Members
400,526
Latest member
Brook1083

Some videos you may like

This Week's Hot Topics

  • VBA (Userform)
    Hi All, I just would like to know why my code isn't working. Here is my VBA code: [CODE=vba]Private Sub OKButton_Click() Dim i As Integer...
  • List box that changes fill color
    Hello, I have gone through so many pages trying to figure this out. I have a 2020 calendar that depending on the day needs to have a certain...
  • Remove duplicates and retain one. Cross-linked cases
    Hi all I ran out of google keywords to use and still couldn't find a reference how to achieve the results of a single count. It would be great if...
  • VBA Copy and Paste With Duplicates
    Hello All, I'm in need of some input. My VBA skills are sub-par at best. I've assembled this code from basic research and it works but is...
  • Macro
    is it possible for a macro to run if the active cell value is different to the value above it
  • IF DATE and TIME
    I currently use this to check if date has passed but i also need to set a time on it too. Is it possible? [CODE=vba]=IF(B:B>TODAY(),"Not...
Top