Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Cells within Cells formula

Hi Guys

This is an example of one of the formulas that I am trying to use.

Dim x As Long
x = 2
Cells(x, "C").Formula = "=(Data!Cells(x, "P")+Data!Cells(x,"R")/24"


It keeps giving me a compiled error, unexpected end of statement. It
keeps pointing to the P and I can't figure out how to get around it.
I've tried single quotation marks, putting them in separate brackets
and what not but it doesn't work. =/ I'm stumped, guys. Help would be
appreciated.


-Simon the newbie

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Cells within Cells formula

You're mixing VBA code into a formula. You can't do that.Try
something like

Cells(x, "C").Formula = "=(Data!P" & x & "+Data!R" & x & ")/24"

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"mortals" wrote in message
oups.com...
Hi Guys

This is an example of one of the formulas that I am trying to
use.

Dim x As Long
x = 2
Cells(x, "C").Formula = "=(Data!Cells(x,
"P")+Data!Cells(x,"R")/24"


It keeps giving me a compiled error, unexpected end of
statement. It
keeps pointing to the P and I can't figure out how to get
around it.
I've tried single quotation marks, putting them in separate
brackets
and what not but it doesn't work. =/ I'm stumped, guys. Help
would be
appreciated.


-Simon the newbie



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Cells within Cells formula

Try this

I use " twice in the formula

Cells(x, "C").Formula = "=(Data!Cells(x, ""P"")+Data!Cells(x,""R"")/24"


--
Regards Ron de Bruin
http://www.rondebruin.nl


"mortals" wrote in message oups.com...
Hi Guys

This is an example of one of the formulas that I am trying to use.

Dim x As Long
x = 2
Cells(x, "C").Formula = "=(Data!Cells(x, "P")+Data!Cells(x,"R")/24"


It keeps giving me a compiled error, unexpected end of statement. It
keeps pointing to the P and I can't figure out how to get around it.
I've tried single quotation marks, putting them in separate brackets
and what not but it doesn't work. =/ I'm stumped, guys. Help would be
appreciated.


-Simon the newbie



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Cells within Cells formula

Forget my stupid answer
See Chip's response

I go to bed <vbg


--
Regards Ron de Bruin
http://www.rondebruin.nl


"mortals" wrote in message oups.com...
Hi Guys

This is an example of one of the formulas that I am trying to use.

Dim x As Long
x = 2
Cells(x, "C").Formula = "=(Data!Cells(x, "P")+Data!Cells(x,"R")/24"


It keeps giving me a compiled error, unexpected end of statement. It
keeps pointing to the P and I can't figure out how to get around it.
I've tried single quotation marks, putting them in separate brackets
and what not but it doesn't work. =/ I'm stumped, guys. Help would be
appreciated.


-Simon the newbie



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Cells within Cells formula

or you can use range

Range("C" & x).Formula = "=(Data!P" & x & " + Data!R" & x & ")/24"




--


Gary


"mortals" wrote in message
oups.com...
Hi Guys

This is an example of one of the formulas that I am trying to use.

Dim x As Long
x = 2
Cells(x, "C").Formula = "=(Data!Cells(x, "P")+Data!Cells(x,"R")/24"


It keeps giving me a compiled error, unexpected end of statement. It
keeps pointing to the P and I can't figure out how to get around it.
I've tried single quotation marks, putting them in separate brackets
and what not but it doesn't work. =/ I'm stumped, guys. Help would be
appreciated.


-Simon the newbie





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Cells within Cells formula

Thanks guys,

It works fine in a simple formula like what I provided. However, when i
tried something more complicated like:

Cells(x, "D").Formula = "=WORKDAY(Data!J" & x & ",Data!C" & x &
",Results!D1:D3))"

It just gives me a application/object-defined error. =/

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Cells within Cells formula

You've got an extra closing parentheses at the very end of the
formula.


"mortals" wrote in message
oups.com...
Thanks guys,

It works fine in a simple formula like what I provided.
However, when i
tried something more complicated like:

Cells(x, "D").Formula = "=WORKDAY(Data!J" & x & ",Data!C" & x &
",Results!D1:D3))"

It just gives me a application/object-defined error. =/



  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Cells within Cells formula

Chip,

You have the eyes of a hawk. I can't believe I missed that double
parenthesis. =/ Since you are on a roll and have been of awesome help
to me, could you help me figure out why these 2 don't work either? I've
checked for double parenthesis, quotations marks and modified it
somewhat but nothing seems to work. =/

Cells(x, "G").Formula = "=IF(Data!L" & x & "<"",IF(Data!M" & x &
"<"",NETWORKDAYS(Data!L" & x & ",Data!M" & x &
",Results!$D$1:$D$3)-1,0),0)"

Cells(x, "J").Formula = "=IF(Data!I" & x & "=1,IF(Data!I" & x &
"<=6,Data!I" & x & ",""),"")"


Thanks in advance

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Cells within Cells formula

In both formulas, you need to double the double quotes (for a
total of four " characters) to insert "" into the formula

Cells(x, "G").Formula = "=IF(Data!L" & x & "<"""",IF(Data!M" & _
x & "<"""",NETWORKDAYS(Data!L" & x & ",Data!M" & _
x & ",Results!$D$1:$D$3)-1,0),0)"

Cells(x, "J").Formula = "=IF(Data!I" & x & "=1,IF(Data!I" & x &
"<=6,Data!I" & x & ",""""),"""")"


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"mortals" wrote in message
oups.com...
Chip,

You have the eyes of a hawk. I can't believe I missed that
double
parenthesis. =/ Since you are on a roll and have been of
awesome help
to me, could you help me figure out why these 2 don't work
either? I've
checked for double parenthesis, quotations marks and modified
it
somewhat but nothing seems to work. =/

Cells(x, "G").Formula = "=IF(Data!L" & x & "<"",IF(Data!M" & x
&
"<"",NETWORKDAYS(Data!L" & x & ",Data!M" & x &
",Results!$D$1:$D$3)-1,0),0)"

Cells(x, "J").Formula = "=IF(Data!I" & x & "=1,IF(Data!I" & x
&
"<=6,Data!I" & x & ",""),"")"


Thanks in advance



  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Cells within Cells formula

chip:

is there any performance or any other reason someone would use cells(y,x)
rather than range(x,y)?

--


Gary


"Chip Pearson" wrote in message
...
In both formulas, you need to double the double quotes (for a total of
four " characters) to insert "" into the formula

Cells(x, "G").Formula = "=IF(Data!L" & x & "<"""",IF(Data!M" & _
x & "<"""",NETWORKDAYS(Data!L" & x & ",Data!M" & _
x & ",Results!$D$1:$D$3)-1,0),0)"

Cells(x, "J").Formula = "=IF(Data!I" & x & "=1,IF(Data!I" & x &
"<=6,Data!I" & x & ",""""),"""")"


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"mortals" wrote in message
oups.com...
Chip,

You have the eyes of a hawk. I can't believe I missed that double
parenthesis. =/ Since you are on a roll and have been of awesome help
to me, could you help me figure out why these 2 don't work either? I've
checked for double parenthesis, quotations marks and modified it
somewhat but nothing seems to work. =/

Cells(x, "G").Formula = "=IF(Data!L" & x & "<"",IF(Data!M" & x &
"<"",NETWORKDAYS(Data!L" & x & ",Data!M" & x &
",Results!$D$1:$D$3)-1,0),0)"

Cells(x, "J").Formula = "=IF(Data!I" & x & "=1,IF(Data!I" & x &
"<=6,Data!I" & x & ",""),"")"


Thanks in advance







  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Cells within Cells formula

Its a matter of syntax and style mostly. The Cells property and
the Range property use different syntaxes, and over time one
develops a stylistic preference. I don't think there is much of a
performance difference between the two, but I've never run any
timing tests.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com






"Gary Keramidas" <GKeramidasATmsn.com wrote in message
...
chip:

is there any performance or any other reason someone would use
cells(y,x) rather than range(x,y)?

--


Gary


"Chip Pearson" wrote in message
...
In both formulas, you need to double the double quotes (for a
total of four " characters) to insert "" into the formula

Cells(x, "G").Formula = "=IF(Data!L" & x & "<"""",IF(Data!M"
& _
x & "<"""",NETWORKDAYS(Data!L" & x & ",Data!M" & _
x & ",Results!$D$1:$D$3)-1,0),0)"

Cells(x, "J").Formula = "=IF(Data!I" & x & "=1,IF(Data!I" & x
& "<=6,Data!I" & x & ",""""),"""")"


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"mortals" wrote in message
oups.com...
Chip,

You have the eyes of a hawk. I can't believe I missed that
double
parenthesis. =/ Since you are on a roll and have been of
awesome help
to me, could you help me figure out why these 2 don't work
either? I've
checked for double parenthesis, quotations marks and modified
it
somewhat but nothing seems to work. =/

Cells(x, "G").Formula = "=IF(Data!L" & x & "<"",IF(Data!M" &
x &
"<"",NETWORKDAYS(Data!L" & x & ",Data!M" & x &
",Results!$D$1:$D$3)-1,0),0)"

Cells(x, "J").Formula = "=IF(Data!I" & x & "=1,IF(Data!I" &
x &
"<=6,Data!I" & x & ",""),"")"


Thanks in advance







  #12   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Cells within Cells formula

ok, thanks. i was just wondering if it was just a preference.

--


Gary


"Chip Pearson" wrote in message
...
Its a matter of syntax and style mostly. The Cells property and the Range
property use different syntaxes, and over time one develops a stylistic
preference. I don't think there is much of a performance difference
between the two, but I've never run any timing tests.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com






"Gary Keramidas" <GKeramidasATmsn.com wrote in message
...
chip:

is there any performance or any other reason someone would use cells(y,x)
rather than range(x,y)?

--


Gary


"Chip Pearson" wrote in message
...
In both formulas, you need to double the double quotes (for a total of
four " characters) to insert "" into the formula

Cells(x, "G").Formula = "=IF(Data!L" & x & "<"""",IF(Data!M" & _
x & "<"""",NETWORKDAYS(Data!L" & x & ",Data!M" & _
x & ",Results!$D$1:$D$3)-1,0),0)"

Cells(x, "J").Formula = "=IF(Data!I" & x & "=1,IF(Data!I" & x &
"<=6,Data!I" & x & ",""""),"""")"


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"mortals" wrote in message
oups.com...
Chip,

You have the eyes of a hawk. I can't believe I missed that double
parenthesis. =/ Since you are on a roll and have been of awesome help
to me, could you help me figure out why these 2 don't work either? I've
checked for double parenthesis, quotations marks and modified it
somewhat but nothing seems to work. =/

Cells(x, "G").Formula = "=IF(Data!L" & x & "<"",IF(Data!M" & x &
"<"",NETWORKDAYS(Data!L" & x & ",Data!M" & x &
",Results!$D$1:$D$3)-1,0),0)"

Cells(x, "J").Formula = "=IF(Data!I" & x & "=1,IF(Data!I" & x &
"<=6,Data!I" & x & ",""),"")"


Thanks in advance









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
Formula refers to empty cells even when cells contains data Monica Rustogi Excel Worksheet Functions 1 February 25th 10 06:56 PM
Setting of input cells as blue font and formula cells as black fon Sunnyskies Excel Discussion (Misc queries) 2 May 14th 07 05:27 PM
Need formula that will sum cells in a column bases on criteria in other cells. Jim Excel Worksheet Functions 3 February 18th 06 03:33 PM
trying to create an (almost) circular formula between cells and data validated cells with lists KR Excel Worksheet Functions 0 May 12th 05 07:21 PM
Copy a formula to a range of cells via VB6 using .Range(Cells(row,col), Cells(row,col)).Formula= statement Kevin Excel Programming 7 October 5th 04 08:11 PM


All times are GMT +1. The time now is 02:11 PM.

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"