ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   With Me statement (https://www.excelbanter.com/excel-programming/392605-me-statement.html)

Capt. Bangs

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!

Chip Pearson

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!



John[_132_]

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.



Chip Pearson

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.



All times are GMT +1. The time now is 03:37 AM.

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