Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default With Me statement

I'm trying to use a block of code to validate the user's data entry in a
form. I copied the relevant portions of code that was suggested by a VBA
book that begins with a "With Me" statment and ends with and "End With"
statement. I keep getting an error message telling me that my code includes
an "End With" statement without a "With" statement (which isn't the case!).
I have used this code before and it worked fine. Any suggestions? Also, I'm
not clear how the application knows that "Me" refers to the user form.

Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default With Me statement

When you are missing the closing element of a code structure (e.g., End If,
End Select, Loop, Until, End With, Next, etc), the compiler throws up an
error indicating that a closing element is missing but often chooses the
wrong element. For example, if you are missing an End If, the compiler may
well say there is a missing End With, even though you do in fact have and
End With.

You need to check that ALL the closing elements are present, e.g., End If
for each If and so on.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting
www.cpearson.com
(email on the web site)

"Capt. Bangs" wrote in message
...
I'm trying to use a block of code to validate the user's data entry in a
form. I copied the relevant portions of code that was suggested by a VBA
book that begins with a "With Me" statment and ends with and "End With"
statement. I keep getting an error message telling me that my code
includes
an "End With" statement without a "With" statement (which isn't the
case!).
I have used this code before and it worked fine. Any suggestions? Also,
I'm
not clear how the application knows that "Me" refers to the user form.

Thanks!


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default With Me statement

This is a pain. Are there any plans to fix this in the future?

John

Chip Pearson wrote:

When you are missing the closing element of a code structure (e.g., End
If, End Select, Loop, Until, End With, Next, etc), the compiler throws
up an error indicating that a closing element is missing but often
chooses the wrong element. For example, if you are missing an End If,
the compiler may well say there is a missing End With, even though you
do in fact have and End With.

You need to check that ALL the closing elements are present, e.g., End
If for each If and so on.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default With Me statement

Are there any plans to fix this in the future?

I doubt it. VBA has remained unchanged since Excel 2000 (VBA Version 6). I
would guess that the next "upgrade" of VBA will actually be a transition to
VB.NET.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting
www.cpearson.com
(email on the web site)

"John" wrote in message
...
This is a pain. Are there any plans to fix this in the future?

John

Chip Pearson wrote:

When you are missing the closing element of a code structure (e.g., End
If, End Select, Loop, Until, End With, Next, etc), the compiler throws up
an error indicating that a closing element is missing but often chooses
the wrong element. For example, if you are missing an End If, the
compiler may well say there is a missing End With, even though you do in
fact have and End With.

You need to check that ALL the closing elements are present, e.g., End If
for each If and so on.

Reply
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
IF statement inside a SUMIF statement.... or alternative method Sungibungi Excel Worksheet Functions 3 December 4th 09 06:22 PM
Reconcile Bank statement & Credit card statement & accounting data Bklynhyc Excel Worksheet Functions 0 October 7th 09 09:07 PM
Embedding an OR statement in an IF statement efficiently Chatnoir11 Excel Discussion (Misc queries) 4 February 2nd 09 08:12 PM
SUMIF statement with AND statement Eric D Excel Discussion (Misc queries) 2 July 14th 08 07:24 PM
appending and IF statement to an existing IF statement spence Excel Worksheet Functions 1 February 28th 06 11:00 PM


All times are GMT +1. The time now is 03:02 PM.

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"