Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Formula Syntax Problem

I would like to end up with a cell to have =10+2 as the formula. I don't just
want the value of 12 dumped into the cell. My attempt is below but I can't
figure out why it bombs.

Range("C" & cntrl - 1).Formula = "=" & Range("C" & cntr1 - 1).value & "+" &
Range("C" & ctrl1).value

Thanks
Bob
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Formula Syntax Problem

It looks like you are using 3 different variable names (and I'm guessing
only one has a value assigned to it). The last character in your first Range
call is a lower case "L", in the other two Range calls it is the number 1,
but in the last Range call the variable does not have the lower case "N" in
it that the other two variables have.

--
Rick (MVP - Excel)


"Bob Zimski" wrote in message
...
I would like to end up with a cell to have =10+2 as the formula. I don't
just
want the value of 12 dumped into the cell. My attempt is below but I can't
figure out why it bombs.

Range("C" & cntrl - 1).Formula = "=" & Range("C" & cntr1 - 1).value & "+"
&
Range("C" & ctrl1).value

Thanks
Bob


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Formula Syntax Problem

Ouch, now that you mention it, it is a lot more visible here than in the VBA
editor window where the l and 1 are almost identical. as for the 'n', ...
been staring into the tube too long.

Thanks for the 'wake up call' :)

"Rick Rothstein" wrote:

It looks like you are using 3 different variable names (and I'm guessing
only one has a value assigned to it). The last character in your first Range
call is a lower case "L", in the other two Range calls it is the number 1,
but in the last Range call the variable does not have the lower case "N" in
it that the other two variables have.

--
Rick (MVP - Excel)


"Bob Zimski" wrote in message
...
I would like to end up with a cell to have =10+2 as the formula. I don't
just
want the value of 12 dumped into the cell. My attempt is below but I can't
figure out why it bombs.

Range("C" & cntrl - 1).Formula = "=" & Range("C" & cntr1 - 1).value & "+"
&
Range("C" & ctrl1).value

Thanks
Bob



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Formula Syntax Problem

It is just the opposite for me... I'm using Courier New in the VBA editor (I
wanted consistent character widths) and Arial in my email/news reader. In
VBA, the top of the one is slanted and the top of the lower case "L" is
horizontal... in my news reader, the two characters look identical.

--
Rick (MVP - Excel)


"Bob Zimski" wrote in message
...
Ouch, now that you mention it, it is a lot more visible here than in the
VBA
editor window where the l and 1 are almost identical. as for the 'n', ...
been staring into the tube too long.

Thanks for the 'wake up call' :)

"Rick Rothstein" wrote:

It looks like you are using 3 different variable names (and I'm guessing
only one has a value assigned to it). The last character in your first
Range
call is a lower case "L", in the other two Range calls it is the number
1,
but in the last Range call the variable does not have the lower case "N"
in
it that the other two variables have.

--
Rick (MVP - Excel)


"Bob Zimski" wrote in message
...
I would like to end up with a cell to have =10+2 as the formula. I don't
just
want the value of 12 dumped into the cell. My attempt is below but I
can't
figure out why it bombs.

Range("C" & cntrl - 1).Formula = "=" & Range("C" & cntr1 - 1).value &
"+"
&
Range("C" & ctrl1).value

Thanks
Bob




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Formula Syntax Problem

By the way, you should (IMHO) always declare (Dim) each variable and you
should use Option Explicit at the top of each module so that VB will alert
you (when you try to run your code) of any variable it encounters that are
not declared. This is extremely helpful in avoiding mistyped names of
variable/function/subs/objects/etc. To implement the automatic placing of
Option Explicit statements at the top of all *new* code windows (this won't
go back and add Option Explicit to code windows already populated with
code), click Tools/Options on the menu bar in the VBA editor, click the
Editor tab and put a check mark next to "Require Variable Declarations". I
would also consider removing the check mark next to "Auto Syntax Check"
(improper syntax will still be flagged in red, but you won't be forced to
correct the syntax right then and there).

--
Rick (MVP - Excel)


"Bob Zimski" wrote in message
...
Ouch, now that you mention it, it is a lot more visible here than in the
VBA
editor window where the l and 1 are almost identical. as for the 'n', ...
been staring into the tube too long.

Thanks for the 'wake up call' :)

"Rick Rothstein" wrote:

It looks like you are using 3 different variable names (and I'm guessing
only one has a value assigned to it). The last character in your first
Range
call is a lower case "L", in the other two Range calls it is the number
1,
but in the last Range call the variable does not have the lower case "N"
in
it that the other two variables have.

--
Rick (MVP - Excel)


"Bob Zimski" wrote in message
...
I would like to end up with a cell to have =10+2 as the formula. I don't
just
want the value of 12 dumped into the cell. My attempt is below but I
can't
figure out why it bombs.

Range("C" & cntrl - 1).Formula = "=" & Range("C" & cntr1 - 1).value &
"+"
&
Range("C" & ctrl1).value

Thanks
Bob






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Formula Syntax Problem

You sold me one several points. Thanks very much.

Bob

"Rick Rothstein" wrote:

By the way, you should (IMHO) always declare (Dim) each variable and you
should use Option Explicit at the top of each module so that VB will alert
you (when you try to run your code) of any variable it encounters that are
not declared. This is extremely helpful in avoiding mistyped names of
variable/function/subs/objects/etc. To implement the automatic placing of
Option Explicit statements at the top of all *new* code windows (this won't
go back and add Option Explicit to code windows already populated with
code), click Tools/Options on the menu bar in the VBA editor, click the
Editor tab and put a check mark next to "Require Variable Declarations". I
would also consider removing the check mark next to "Auto Syntax Check"
(improper syntax will still be flagged in red, but you won't be forced to
correct the syntax right then and there).

--
Rick (MVP - Excel)


"Bob Zimski" wrote in message
...
Ouch, now that you mention it, it is a lot more visible here than in the
VBA
editor window where the l and 1 are almost identical. as for the 'n', ...
been staring into the tube too long.

Thanks for the 'wake up call' :)

"Rick Rothstein" wrote:

It looks like you are using 3 different variable names (and I'm guessing
only one has a value assigned to it). The last character in your first
Range
call is a lower case "L", in the other two Range calls it is the number
1,
but in the last Range call the variable does not have the lower case "N"
in
it that the other two variables have.

--
Rick (MVP - Excel)


"Bob Zimski" wrote in message
...
I would like to end up with a cell to have =10+2 as the formula. I don't
just
want the value of 12 dumped into the cell. My attempt is below but I
can't
figure out why it bombs.

Range("C" & cntrl - 1).Formula = "=" & Range("C" & cntr1 - 1).value &
"+"
&
Range("C" & ctrl1).value

Thanks
Bob




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
DAO Syntax Problem drinese18 Excel Programming 12 January 18th 08 02:54 PM
IF formula syntax problem Stephen Excel Programming 7 July 18th 06 04:21 PM
syntax problem dorre Excel Programming 3 March 20th 06 05:20 PM
Syntax problem Alex H Excel Worksheet Functions 1 July 2nd 05 08:23 AM
Syntax Problem with formula code Todd Huttenstine Excel Programming 7 May 10th 04 05:35 PM


All times are GMT +1. The time now is 01:57 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"