ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Capitalization in Declarations (https://www.excelbanter.com/excel-programming/286132-capitalization-declarations.html)

Phil Hageman[_3_]

Capitalization in Declarations
 
My understanding is that in declaring variables, if the
data type is, say, "Range", with a capital "R", it is
recognized as a valid data type in VBA. If, when typing
in the lower-case text the "r" does not capitalize, does
this mean VBA does not recognize the Dim line
with "range" as a valid declaration? If so, what to do
about it?
Thanks, Phil

Harald Staff

Capitalization in Declarations
 
Hi Phil

If i get this right: You write
Dim kaBoom as range
and range doesn't correct itself to Range ?
Yes, something is wrong. But make sure that you are actually finishing editing that line.
Click somewhere completely elsewhere and see if it happens.

Autocorrect and intellisense (smart suggestions) don't work as intended when something's
wrong. The error might be as simple as that two Subs has identical names or a single
variable is declared several places public/private/locally. Or it may be something quite
serious, but that's rare. And never during christmas.

--
HTH. Best wishes Harald
Followup to newsgroup only please.

"Phil Hageman" wrote in message
...
My understanding is that in declaring variables, if the
data type is, say, "Range", with a capital "R", it is
recognized as a valid data type in VBA. If, when typing
in the lower-case text the "r" does not capitalize, does
this mean VBA does not recognize the Dim line
with "range" as a valid declaration? If so, what to do
about it?
Thanks, Phil




J.E. McGimpsey

Capitalization in Declarations
 
It means you've declared a variable named "range". The VBE will
override the type capitalization with the variable one.

In general, declaring a variable with a VBA keyword is a bad idea,
not only for this reason, but because of the other confusion it can
cause the reader.


In article ,
"Phil Hageman" wrote:

My understanding is that in declaring variables, if the
data type is, say, "Range", with a capital "R", it is
recognized as a valid data type in VBA. If, when typing
in the lower-case text the "r" does not capitalize, does
this mean VBA does not recognize the Dim line
with "range" as a valid declaration? If so, what to do
about it?
Thanks, Phil


Phil Hageman[_3_]

Capitalization in Declarations
 
Mr. McGimplsey, Could this be the problem in the
12/22 "Tweek" thread? How do I hunt for the problem?
Thanks, Phil
-----Original Message-----
It means you've declared a variable named "range". The

VBE will
override the type capitalization with the variable one.

In general, declaring a variable with a VBA keyword is a

bad idea,
not only for this reason, but because of the other

confusion it can
cause the reader.


In article ,
"Phil Hageman"

wrote:

My understanding is that in declaring variables, if the
data type is, say, "Range", with a capital "R", it is
recognized as a valid data type in VBA. If, when

typing
in the lower-case text the "r" does not capitalize,

does
this mean VBA does not recognize the Dim line
with "range" as a valid declaration? If so, what to do
about it?
Thanks, Phil

.


Tom Ogilvy

Capitalization in Declarations
 
Phil,
opening JE's file:
I would assume you are supposed to change the number in column X19 for
example and see that the code is correctly updating the appropriate cells?
Then look in the worksheet code module and use the code there in your
workbook.

--------------------

To correct your range problem. First make sure you don't have

Dim range as Range
or have range as an argument to a function.

then go to a general module and put in

Public Range as String

Then select the declaration and delete it.

This should clear up your capitalization problem although I don't think it
is contributing to whatever problem you seem to think you are having.

JE was referring to you changing the subject line in your post.


--
Regards,
Tom Ogilvy
"Phil Hageman" wrote in message
...
Mr. McGimplsey, Could this be the problem in the
12/22 "Tweek" thread? How do I hunt for the problem?
Thanks, Phil
-----Original Message-----
It means you've declared a variable named "range". The

VBE will
override the type capitalization with the variable one.

In general, declaring a variable with a VBA keyword is a

bad idea,
not only for this reason, but because of the other

confusion it can
cause the reader.


In article ,
"Phil Hageman"

wrote:

My understanding is that in declaring variables, if the
data type is, say, "Range", with a capital "R", it is
recognized as a valid data type in VBA. If, when

typing
in the lower-case text the "r" does not capitalize,

does
this mean VBA does not recognize the Dim line
with "range" as a valid declaration? If so, what to do
about it?
Thanks, Phil

.




J.E. McGimpsey

Capitalization in Declarations
 
thanks for the added explanation, Tom.

One minor addition: A manual change in U19 will show up as a
corresponding change in X19. A change in AM19 will show up as a
corresponding change in AP19, etc. A change in AD19 will not show up
in AG19, since P11 and V11 are blank.

In article ,
"Tom Ogilvy" wrote:

Phil,
opening JE's file:
I would assume you are supposed to change the number in column X19 for
example and see that the code is correctly updating the appropriate cells?
Then look in the worksheet code module and use the code there in your
workbook.

--------------------

To correct your range problem. First make sure you don't have

Dim range as Range
or have range as an argument to a function.

then go to a general module and put in

Public Range as String

Then select the declaration and delete it.

This should clear up your capitalization problem although I don't think it
is contributing to whatever problem you seem to think you are having.

JE was referring to you changing the subject line in your post.


Mr. Clean[_2_]

Capitalization in Declarations
 
In article ,
says...
It means you've declared a variable named "range". The VBE will
override the type capitalization with the variable one.

In general, declaring a variable with a VBA keyword is a bad idea,
not only for this reason, but because of the other confusion it can
cause the reader.

Why would VBA allow this at all, anyway???


Tom Ogilvy

Capitalization in Declarations
 
Working from memory - the trigger columns are as you say. Thanks for the
correction.

--
Regards,
Tom Ogilvy

"J.E. McGimpsey" wrote in message
...
thanks for the added explanation, Tom.

One minor addition: A manual change in U19 will show up as a
corresponding change in X19. A change in AM19 will show up as a
corresponding change in AP19, etc. A change in AD19 will not show up
in AG19, since P11 and V11 are blank.

In article ,
"Tom Ogilvy" wrote:

Phil,
opening JE's file:
I would assume you are supposed to change the number in column X19 for
example and see that the code is correctly updating the appropriate

cells?
Then look in the worksheet code module and use the code there in your
workbook.

--------------------

To correct your range problem. First make sure you don't have

Dim range as Range
or have range as an argument to a function.

then go to a general module and put in

Public Range as String

Then select the declaration and delete it.

This should clear up your capitalization problem although I don't think

it
is contributing to whatever problem you seem to think you are having.

JE was referring to you changing the subject line in your post.




Phil Hageman[_3_]

Worksheet Sample Created
 
Tom and J.E.

I have skinnied down a sample worksheet containing the
complete "Tweek" problem. Can I please send it to you - I
know this is not a difficult coding exercise for you guys,
it's me - I just can't get my points across.

Phil
-----Original Message-----
thanks for the added explanation, Tom.

One minor addition: A manual change in U19 will show up

as a
corresponding change in X19. A change in AM19 will show

up as a
corresponding change in AP19, etc. A change in AD19 will

not show up
in AG19, since P11 and V11 are blank.

In article ,
"Tom Ogilvy" wrote:

Phil,
opening JE's file:
I would assume you are supposed to change the number in

column X19 for
example and see that the code is correctly updating the

appropriate cells?
Then look in the worksheet code module and use the code

there in your
workbook.

--------------------

To correct your range problem. First make sure you

don't have

Dim range as Range
or have range as an argument to a function.

then go to a general module and put in

Public Range as String

Then select the declaration and delete it.

This should clear up your capitalization problem

although I don't think it
is contributing to whatever problem you seem to think

you are having.

JE was referring to you changing the subject line in

your post.
.


Phil Hageman[_3_]

Worksheet Sample Created
 
Tom and J.E.

I have skinnied down a sample worksheet containing the
complete "Tweek" problem. Can I please send it to you - I
know this is not a difficult coding exercise for you guys,
it's me - I just can't get my points across.

Phil
-----Original Message-----
Working from memory - the trigger columns are as you

say. Thanks for the
correction.

--
Regards,
Tom Ogilvy

"J.E. McGimpsey" wrote in message
news:jemcgimpsey-

...
thanks for the added explanation, Tom.

One minor addition: A manual change in U19 will show up

as a
corresponding change in X19. A change in AM19 will show

up as a
corresponding change in AP19, etc. A change in AD19

will not show up
in AG19, since P11 and V11 are blank.

In article ,
"Tom Ogilvy" wrote:

Phil,
opening JE's file:
I would assume you are supposed to change the number

in column X19 for
example and see that the code is correctly updating

the appropriate
cells?
Then look in the worksheet code module and use the

code there in your
workbook.

--------------------

To correct your range problem. First make sure you

don't have

Dim range as Range
or have range as an argument to a function.

then go to a general module and put in

Public Range as String

Then select the declaration and delete it.

This should clear up your capitalization problem

although I don't think
it
is contributing to whatever problem you seem to think

you are having.

JE was referring to you changing the subject line in

your post.


.


Tom Ogilvy

Worksheet Sample Created
 
I answered several hours ago that you can.



--
Regards,
Tom Ogilvy

"Phil Hageman" wrote in message
...
Tom and J.E.

I have skinnied down a sample worksheet containing the
complete "Tweek" problem. Can I please send it to you - I
know this is not a difficult coding exercise for you guys,
it's me - I just can't get my points across.

Phil
-----Original Message-----
Working from memory - the trigger columns are as you

say. Thanks for the
correction.

--
Regards,
Tom Ogilvy

"J.E. McGimpsey" wrote in message
news:jemcgimpsey-

...
thanks for the added explanation, Tom.

One minor addition: A manual change in U19 will show up

as a
corresponding change in X19. A change in AM19 will show

up as a
corresponding change in AP19, etc. A change in AD19

will not show up
in AG19, since P11 and V11 are blank.

In article ,
"Tom Ogilvy" wrote:

Phil,
opening JE's file:
I would assume you are supposed to change the number

in column X19 for
example and see that the code is correctly updating

the appropriate
cells?
Then look in the worksheet code module and use the

code there in your
workbook.

--------------------

To correct your range problem. First make sure you

don't have

Dim range as Range
or have range as an argument to a function.

then go to a general module and put in

Public Range as String

Then select the declaration and delete it.

This should clear up your capitalization problem

although I don't think
it
is contributing to whatever problem you seem to think

you are having.

JE was referring to you changing the subject line in

your post.


.




J.E. McGimpsey

Capitalization in Declarations
 
because it's trying to allow maximum flexibility. The context
determines how it's interpreted

Dim range As range

is unambiguous, as is

Dim a As range

or

range.Value, range.Count, etc.


Now, where it starts to get strange is when you define range as a
Type. Range is not a VBA type (like Date, Boolean, etc.) The
statement

Dim r As Range

is really shorthand for

Dim r As Excel.Range

so you can overload the range type:

Type range
myname As String
myaddress As String
mycity As String
mystate As String
End Type

Public Sub try()
Dim home As range
Dim b As Excel.range

home.myname = "J.E."
Debug.Print home.myname
Set b = range("A1")
Debug.Print b.Value
End Sub


But that can get sort of confusing...



In article ,
Mr. Clean wrote:

In article ,
says...
It means you've declared a variable named "range". The VBE will
override the type capitalization with the variable one.

In general, declaring a variable with a VBA keyword is a bad idea,
not only for this reason, but because of the other confusion it can
cause the reader.

Why would VBA allow this at all, anyway???


Tom Ogilvy

Worksheet Sample Created
 
Problem is mostly merged cells.

--
Regards,
Tom Ogilvy

Phil Hageman wrote in message
...
Tom and J.E.

I have skinnied down a sample worksheet containing the
complete "Tweek" problem. Can I please send it to you - I
know this is not a difficult coding exercise for you guys,
it's me - I just can't get my points across.

Phil
-----Original Message-----
thanks for the added explanation, Tom.

One minor addition: A manual change in U19 will show up

as a
corresponding change in X19. A change in AM19 will show

up as a
corresponding change in AP19, etc. A change in AD19 will

not show up
in AG19, since P11 and V11 are blank.

In article ,
"Tom Ogilvy" wrote:

Phil,
opening JE's file:
I would assume you are supposed to change the number in

column X19 for
example and see that the code is correctly updating the

appropriate cells?
Then look in the worksheet code module and use the code

there in your
workbook.

--------------------

To correct your range problem. First make sure you

don't have

Dim range as Range
or have range as an argument to a function.

then go to a general module and put in

Public Range as String

Then select the declaration and delete it.

This should clear up your capitalization problem

although I don't think it
is contributing to whatever problem you seem to think

you are having.

JE was referring to you changing the subject line in

your post.
.




J.E. McGimpsey

Worksheet Sample Created
 
<sigh

Hard to remotely diagnose, certainly.

In article ,
"Tom Ogilvy" wrote:

Problem is mostly merged cells.


Phil Hageman[_3_]

Send Worksheet?
 
J.E., If you wish, I can e-mail the worksheet.
P
-----Original Message-----
<sigh

Hard to remotely diagnose, certainly.

In article ,
"Tom Ogilvy" wrote:

Problem is mostly merged cells.

.


Tom Ogilvy

Send Worksheet?
 
You didn't receive the sheet I fixed?

--
Regards,
Tom Ogilvy

Phil Hageman wrote in message
...
J.E., If you wish, I can e-mail the worksheet.
P
-----Original Message-----
<sigh

Hard to remotely diagnose, certainly.

In article ,
"Tom Ogilvy" wrote:

Problem is mostly merged cells.

.




Tom Ogilvy

Send Worksheet?
 
Nevermind. I received your email.

--
regards,
Tom Ogilvy

Tom Ogilvy wrote in message
...
You didn't receive the sheet I fixed?

--
Regards,
Tom Ogilvy

Phil Hageman wrote in message
...
J.E., If you wish, I can e-mail the worksheet.
P
-----Original Message-----
<sigh

Hard to remotely diagnose, certainly.

In article ,
"Tom Ogilvy" wrote:

Problem is mostly merged cells.
.







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

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