LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Need help in excel with "Statement invalid outside Type block. " error

I have a cell that I want to display a message box for. The cell
should not contain more than 28 characters. If it does I want to
display a message box that tells the user how many characters they
entered and how many characters to remove from their entry. This is
my code.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim cce17 As Double
If Not Application.Intersect(Target, Range("E17")) Is Nothing Then
cce17 = Len(E17)
If cce17 28 Then
MsgBox("You have entered a value in this field that is" &
cce17 & " characters in length. You will need to shorten your entry
by " & 28 - cce17 & "characters.", vbAbortRetryIgnore, "InvalidEntry
") As VbMsgBoxResult
End If
End If
End Sub

When I try to compile the code I get an error that says
Compile error:
Statement invalid outside Type block.


I know this is probably simple but I am a beginner to VBA and have
been unable to figure it out.

Thanks,
Brent Blevins
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error "invalid data source reference" for pivot table Manny Excel Worksheet Functions 6 April 5th 23 02:58 PM
How do I correct Query error "Invalid bracketing of name 'xls.'." Halp0o9i8 Excel Discussion (Misc queries) 0 August 22nd 08 04:52 AM
error: "invalid character in text conent" How do I open this file RTH Excel Discussion (Misc queries) 5 April 23rd 06 03:04 PM
"Invalid Web Query" error on opening a 2003 worksheet Linus Excel Discussion (Misc queries) 0 February 21st 06 04:55 PM
"Run-time error 91: Object variable or With block not set" Snedker Excel Programming 0 January 10th 04 09:37 AM


All times are GMT +1. The time now is 08:21 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"