Syntax or Something is KILLING Me

S

Strong Eagle

Folks, call me stupid, call me an occassional VB player but I cannot figure
out what is happening.

If I execute this statement:

Sheets("Estimator").Range("E14").NumberFormatLocal = CurrFormat

It works just fine. However, if I make things slightly more complex such as:

Const WorkColEntry = "E"
ComboRow = Str(ComboBox1.ListIndex) ' happens to be 14

Sheets("Estimator").Range(WorkColEntry + ComboRow).NumberFormatLocal =
CurrFormat

This statement blows up with an error:

Run-time error 104, Application-defined or object-defined error,

A very abstruse error definition I might add. In debug of the statement in
question, WorkColEntry is "E" and ComboRow is "14".

So what gives? It is 10:45 PM here in Singapore. To heck with this. Time
for sleep and a game of golf tomorrow.
 
P

p45cal

Should
Sheets("Estimator").Range(WorkColEntry + ComboRow).NumberFormatLocal =
CurrFormat

Sheets("Estimator").Range(WorkColEntry & ComboRow).NumberFormatLocal =
CurrFormat
 
J

JW

You need to use an ampersand instead of a + sign.
Sheets("Estimator").Range(WorkColEntry & comborow) _
.NumberFormatLocal = CurrFormat
 
S

Strong Eagle

No difference - same error with &

p45cal said:
Should
Sheets("Estimator").Range(WorkColEntry + ComboRow).NumberFormatLocal =
CurrFormat

Sheets("Estimator").Range(WorkColEntry & ComboRow).NumberFormatLocal =
CurrFormat
 
P

p45cal

better:
change
ComboRow = Str(ComboBox1.ListIndex)
to
ComboRow = Trim(Str(ComboBox1.ListIndex))
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top