Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.newusers,microsoft.public.excel.misc,microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Problem in setting Excel formula through VB

When I set this formula through VB code,



code:
--------------------------------------------------------------------------------
=((D6*G6)+(E6*1.5*G6)+I6+J6+K6+L6)
--------------------------------------------------------------------------------


for a cell it makes this formula the text of the cell and not the
formula.

Here's my code:


code:
--------------------------------------------------------------------------------
StrFormula = " =((" & GetColumnAlphabet(colRegularHours) &
LngCurrentRow & "*" & GetColumnAlphabet(colPayRate) & LngCurrentRow &
")" & _
"+(" & GetColumnAlphabet(colOvertime) & LngCurrentRow &
"*1.5*" & GetColumnAlphabet(colPayRate) & LngCurrentRow & ")" & _
"+" & GetColumnAlphabet(colSalary) & LngCurrentRow & "+" &
GetColumnAlphabet(colCommission) & LngCurrentRow & _
"+" & GetColumnAlphabet(colBonus) & LngCurrentRow & "+" &
GetColumnAlphabet(colOther) & LngCurrentRow & ")"
Debug.Print StrFormula
Range(GetColumnAlphabet(colGrossTotal) &
LngCurrentRow).Formula = StrFormula
--------------------------------------------------------------------------------


What could be the problem?
  #2   Report Post  
Posted to microsoft.public.excel.newusers,microsoft.public.excel.misc,microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Problem in setting Excel formula through VB

Hi
have you checked the cell is not formated as 'Text'?

--
Regards
Frank Kabel
Frankfurt, Germany


Sathyaish wrote:
When I set this formula through VB code,



code:
---------------------------------------------------------------------

-----------
=((D6*G6)+(E6*1.5*G6)+I6+J6+K6+L6)
---------------------------------------------------------------------

-----------


for a cell it makes this formula the text of the cell and not the
formula.

Here's my code:


code:
---------------------------------------------------------------------

-----------
StrFormula = " =((" & GetColumnAlphabet(colRegularHours) &
LngCurrentRow & "*" & GetColumnAlphabet(colPayRate) & LngCurrentRow &
")" & _
"+(" & GetColumnAlphabet(colOvertime) & LngCurrentRow &
"*1.5*" & GetColumnAlphabet(colPayRate) & LngCurrentRow & ")" & _
"+" & GetColumnAlphabet(colSalary) & LngCurrentRow & "+" &
GetColumnAlphabet(colCommission) & LngCurrentRow & _
"+" & GetColumnAlphabet(colBonus) & LngCurrentRow & "+" &
GetColumnAlphabet(colOther) & LngCurrentRow & ")"
Debug.Print StrFormula
Range(GetColumnAlphabet(colGrossTotal) &
LngCurrentRow).Formula = StrFormula
---------------------------------------------------------------------

-----------


What could be the problem?


  #3   Report Post  
Posted to microsoft.public.excel.newusers,microsoft.public.excel.misc,microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Problem in setting Excel formula through VB

Make sure that the target cells are formatted as General and not Text.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Sathyaish" wrote in message
m...
When I set this formula through VB code,



code:
--------------------------------------------------------------------------

------
=((D6*G6)+(E6*1.5*G6)+I6+J6+K6+L6)
--------------------------------------------------------------------------

------


for a cell it makes this formula the text of the cell and not the
formula.

Here's my code:


code:
--------------------------------------------------------------------------

------
StrFormula = " =((" & GetColumnAlphabet(colRegularHours) &
LngCurrentRow & "*" & GetColumnAlphabet(colPayRate) & LngCurrentRow &
")" & _
"+(" & GetColumnAlphabet(colOvertime) & LngCurrentRow &
"*1.5*" & GetColumnAlphabet(colPayRate) & LngCurrentRow & ")" & _
"+" & GetColumnAlphabet(colSalary) & LngCurrentRow & "+" &
GetColumnAlphabet(colCommission) & LngCurrentRow & _
"+" & GetColumnAlphabet(colBonus) & LngCurrentRow & "+" &
GetColumnAlphabet(colOther) & LngCurrentRow & ")"
Debug.Print StrFormula
Range(GetColumnAlphabet(colGrossTotal) &
LngCurrentRow).Formula = StrFormula
--------------------------------------------------------------------------

------


What could be the problem?



  #4   Report Post  
Posted to microsoft.public.excel.newusers,microsoft.public.excel.misc,microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default Problem in setting Excel formula through VB

Watch out for the leading spaces!

StrFormula = " =((" & .....

StrFormula = "=((" & .....

Sathyaish wrote:

When I set this formula through VB code,

code:
--------------------------------------------------------------------------------
=((D6*G6)+(E6*1.5*G6)+I6+J6+K6+L6)
--------------------------------------------------------------------------------

for a cell it makes this formula the text of the cell and not the
formula.

Here's my code:

code:
--------------------------------------------------------------------------------
StrFormula = " =((" & GetColumnAlphabet(colRegularHours) &
LngCurrentRow & "*" & GetColumnAlphabet(colPayRate) & LngCurrentRow &
")" & _
"+(" & GetColumnAlphabet(colOvertime) & LngCurrentRow &
"*1.5*" & GetColumnAlphabet(colPayRate) & LngCurrentRow & ")" & _
"+" & GetColumnAlphabet(colSalary) & LngCurrentRow & "+" &
GetColumnAlphabet(colCommission) & LngCurrentRow & _
"+" & GetColumnAlphabet(colBonus) & LngCurrentRow & "+" &
GetColumnAlphabet(colOther) & LngCurrentRow & ")"
Debug.Print StrFormula
Range(GetColumnAlphabet(colGrossTotal) &
LngCurrentRow).Formula = StrFormula
--------------------------------------------------------------------------------

What could be the problem?


--

Dave Peterson

  #5   Report Post  
Posted to microsoft.public.excel.newusers,microsoft.public.excel.misc,microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Problem in setting Excel formula through VB

Dave Peterson ) said: Watch out for the leading spaces!

Sathyaish replies: Dave, you're the man! Thanks so much.

Regards,
Sathyaish Chakravarthy.
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
Need help with setting up IF formula in Excel Sharon[_2_] Links and Linking in Excel 2 February 7th 08 02:23 AM
Excel setting problem Rajula Excel Discussion (Misc queries) 4 January 26th 07 09:29 AM
problem setting formula elizabeth Excel Worksheet Functions 1 June 29th 06 02:19 AM
i need help setting up a formula in excel Avril M. Excel Discussion (Misc queries) 1 March 9th 06 02:58 PM
Need help setting up a >< IF formula in Excel, Sheryl Excel Worksheet Functions 2 May 18th 05 07:22 PM


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