Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default formula in VB not working

I have several columns of figures with totals at the bottom. The leftmost
column is the grand total. I need to calculate what percentages the subtotals
are of the grand total.
This code sums the column, and works fine:
Dim per1 As String
per1 = "=sum(" & r3 & ":" & r4 & ")"
ActiveCell.formula = per1

This code 'should' calculate the percentage, but the debugger sticks on the
final line:
Dim per2 As String
per2 = "=sum(" & r3 & ":" & r4 & ")/(=sum(" & r1 & ":" & r2 & ")/100)"
ActiveCell.formula = per2

What have I done?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,440
Default formula in VB not working

per2 = "=sum(" & r3 & ":" & r4 & ")/(sum(" & r1 & ":" & r2 & ")/100)"

That is, no "=" sign before the 2nd Sum. Of course I don't know if your r1
and r1 are right.
You can always test the formula by entering it on the worksheet first and
then read it in VBA with the .Formula property

--
Kind regards,

Niek Otten


"Josie" <zeiderzeeAThotmailDOTcoDOTuk(DONOTSPAM) wrote in message
...
I have several columns of figures with totals at the bottom. The leftmost
column is the grand total. I need to calculate what percentages the
subtotals
are of the grand total.
This code sums the column, and works fine:
Dim per1 As String
per1 = "=sum(" & r3 & ":" & r4 & ")"
ActiveCell.formula = per1

This code 'should' calculate the percentage, but the debugger sticks on
the
final line:
Dim per2 As String
per2 = "=sum(" & r3 & ":" & r4 & ")/(=sum(" & r1 & ":" & r2 & ")/100)"
ActiveCell.formula = per2

What have I done?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default formula in VB not working

Hi Niek. Thanks. That's fixed it!

"Niek Otten" wrote:

per2 = "=sum(" & r3 & ":" & r4 & ")/(sum(" & r1 & ":" & r2 & ")/100)"

That is, no "=" sign before the 2nd Sum. Of course I don't know if your r1
and r1 are right.
You can always test the formula by entering it on the worksheet first and
then read it in VBA with the .Formula property

--
Kind regards,

Niek Otten


"Josie" <zeiderzeeAThotmailDOTcoDOTuk(DONOTSPAM) wrote in message
...
I have several columns of figures with totals at the bottom. The leftmost
column is the grand total. I need to calculate what percentages the
subtotals
are of the grand total.
This code sums the column, and works fine:
Dim per1 As String
per1 = "=sum(" & r3 & ":" & r4 & ")"
ActiveCell.formula = per1

This code 'should' calculate the percentage, but the debugger sticks on
the
final line:
Dim per2 As String
per2 = "=sum(" & r3 & ":" & r4 & ")/(=sum(" & r1 & ":" & r2 & ")/100)"
ActiveCell.formula = per2

What have I done?




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
A formula not working as the result of a previous formula? Ed[_7_] Excel Discussion (Misc queries) 5 July 21st 09 06:22 PM
Formula not working, help SunshineinFt.Myers[_2_] Excel Worksheet Functions 3 March 11th 09 08:58 PM
formula not working JayPee New Users to Excel 2 August 8th 08 10:22 PM
IF Formula Not Working novice Excel Worksheet Functions 4 July 31st 08 11:54 PM
Formula not working Carolina Girl Excel Worksheet Functions 4 May 16th 08 05:26 PM


All times are GMT +1. The time now is 03:15 AM.

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"