LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 106
Default Assignment to constant not permitted

Got it!
Thx

"Norman Jones" wrote in message
...
Hi Grace,

We are back at the start!

Originally, you did not dim your variables (or use Option explicit at the
top of your module). In these circumstances, VBA objected to the Default
variable because this is a reserved word having a special significance in
VBA.

Had you, however, dimmed you the 'Default' variable, VBA would not have

have
thrown up the 'assignment to constant is not permitted error message.

Nonetheless, I repeat my original advice: use Option Explicit, dim all

your
variables and avoid reserved words!


---
Regards,
Norman



"Grace" wrote in message
...
I'm a bit confused. Originally, you said:

Change the line: Default = ""
to: strDefault = ""
as this is a VBA reserved name.

I thought this was because I was having macro crashing problems. But

did
that have nothing to do with my macro crashing? And, are you saying, it
shouldn't be just "default", but other than that, it could be anything

at
all, like =InputBox(Joe, Harry, Jerry)?

Thanks,
Grace

"Norman Jones" wrote in message
...
Hi Grace,

The choice of variable names is primarily a matter of choice and

personal
preferance.

For me, the main considerations are convenience and readability -

readabilty
by me and (possibly) by others.

I (non-uniquely!) tend to prefix a string variable with str as this
immediately informs me (as indeed it informed you!) of the variable

type,
thus rendering my code more immediately comprehensible.
As for range variables I tend,inconsistently, to use a rng prefix or
suffix, e.g, Rng, Rng1 or myRng bigRng, copyRng, DestRng etc accoding

to
seems most immediately descriptive.
I could continue in similar fashion for other variable types but more
informative (and useful) would be to direct you to look at the

approaches
of
others who regularly contribute to the Excel newsgroups. In

particular,
however, I would direct your attention to Chip Pearson's web
site:http://www.cpearson.com/excel/topic.htm
which is not only replete with useful and informative code but

which
uses
an idiosyncratic variable naming style which is (imho) a model of

clarity.

---
Regards,
Norman



"Grace" wrote in message
...
I assume the strDefault and strTitle is for strings and that there

are
analogs for things dimensioned as other types. What do you use for
workbook, long, range, date, etc?

Thanks,
Grace

"Norman Jones" wrote in message
...
Hi Grace,

Change the line: Default = ""
to: strDefault = ""
as this is a VBA reserved name.

It is also highly advisable to head your module with : Option

Explicit

and appropriately dim your variables.

If you were to do this, your code might look like this:

Sub Test()
Dim strMessage As String, StrTitle As String, _
StrDefault As String, StrMGR_LONG_NAME As String

strMessage = "ENTER LONG DISPLAY NAME OF WRAP MANAGER"
StrTitle = ""
StrDefault = ""
StrMGR_LONG_NAME = InputBox(strMessage, StrTitle, StrDefault)
Sheets("INPUTS").Range("C11").Value = StrMGR_LONG_NAME

End Sub

---
Regards,
Norman


"Grace" wrote in message
...
I just found an old sample I was trying to adapt for a message

box.
But,
in
my new spreadsheet, the macro crashes when I try to run it. It

stops
on
the
Default command and says "assignment to constant not permitted".

What
am
I
forgetting? Here is the macro:

Message = "ENTER LONG DISPLAY NAME OF WRAP MANAGER"
Title = ""
Default = ""
MGR_LONG_NAME = InputBox(Message, Title, Default)
Sheets("INPUTS").Range("C11").Value = MGR_LONG_NAME

Thanks,
Grace












 
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
Calculate the amount of time over a permitted amount (12 hours) Steve M Excel Discussion (Misc queries) 9 June 2nd 10 09:25 PM
How to give an error message if a cell value entered is larger than permitted Colin Hayes Excel Discussion (Misc queries) 7 May 16th 07 02:39 PM
Constant loan payments vs. constant payments of principal lalli945 Excel Worksheet Functions 3 December 20th 06 10:33 PM
point assignment Blah Excel Discussion (Misc queries) 4 July 21st 06 12:29 AM
Key Assignment Log Norma Excel Discussion (Misc queries) 0 May 12th 05 04:10 PM


All times are GMT +1. The time now is 01:11 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"