Scary and Confusing Formula Problem :: MrExcel Message Board



 FAQFAQ
   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   FavoritesFavorites   StatisticsStatistics 
 RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
Online StoreOnline Store

MrExcel Message Board Forum Index -> Excel Questions

Scary and Confusing Formula Problem
Post new topic   Reply to topic
Last Thread | Next Thread  >   Printable version
  Author    Thread

Yesuslave
Board Regular


Joined: 19 Sep 2003
Posts: 97
Location: New Jersey
Flag: Usa

Status: Offline

 Reply with quote  

Scary and Confusing Formula Problem

Hi all,

OK, this is a crazy thing in excel that neither my partner nor I can figure out.

I have a formula that I have inserted into a cell using a macro that basically simply adds up cells and returns the sum. It will not return anything other than 0 if one of the cells it adds up has a sum of 0. Why is this?

Has anyone ever heard of somthing like this? i mean, it makes sense if it is multiplication, but this is addition. All of the cells are formatted exactly the same. Also, if I copy the formula in the cell that works, and then paste it on top of itself (effectively simply replacing it with itself) it returns 0, when before it had the accurate sum.


HEEEEELLLLLLLPPPPPPP!!!!!


Joshua Wise

Post Fri Sep 19, 2003 7:48 pm 
 View user's profile Send private message Send e-mail AIM Address Yahoo Messenger

just_jon
MrExcel MVP


Joined: 04 Sep 2002
Posts: 4007
Location: Huntsville AL
Flag: Blank

Status: Offline

 Reply with quote  

Re: Scary and Confusing Formula Problem

Can you post the macro?

EDIT: And the formula which yields 0 when copied over itself.
_________________
just_jon
Book of the Month: I'm Not Really an MVP, I Just Play One on TV [j. jon, 2004]

Post Fri Sep 19, 2003 8:01 pm 
 View user's profile Send private message

Yesuslave
Board Regular


Joined: 19 Sep 2003
Posts: 97
Location: New Jersey
Flag: Usa

Status: Offline

 Reply with quote  

Re: Scary and Confusing Formula Problem

This code isn't annotated yet, so it might be somewhat confusing. But the point is that the code looks for cells that contain things like "=SUM(F5:F10)" which may or may not contain a total of 0.00. If it does contain a sum of 0.00, the whole total in the end ends up as zero, even if other cells in the Sum have non zero totals.


Function FinalTotals(strMarker As String)

Dim strMarkerCell As String
Dim i As Integer
Dim x1, x2, x3, x4, x5, x6 As Integer
Dim y1, y2, y3, y4, y5 As Integer
Dim strFormula As String

Range("C2").Select
i = 0
x1 = 0
x2 = 0
x3 = 0
x4 = 0
x5 = 0
x6 = 0


Do Until ActiveCell.Text = strMarker
ActiveCell.Offset(1, 0).Select
Loop

strMarkerCell = ActiveCell.Address


Do Until i = 6
Do Until ActiveCell.Text = strMarker
ActiveCell.Offset(1, 0).Select
Loop
If x6 = 0 Then
x6 = ActiveCell.Row
ElseIf x6 <> 0 And x5 = 0 Then
x5 = ActiveCell.Row
ElseIf x5 <> 0 And x4 = 0 Then
x4 = ActiveCell.Row
ElseIf x4 <> 0 And x3 = 0 Then
x3 = ActiveCell.Row
ElseIf x3 <> 0 And x2 = 0 Then
x2 = ActiveCell.Row
ElseIf x2 <> 0 And x1 = 0 Then
x1 = ActiveCell.Row
End If
ActiveCell.Offset(1, 0).Select
i = i + 1
Loop

ActiveCell.Offset(-1, 0).Select

y1 = x1 - x2
y2 = x1 - x3
y3 = x1 - x4
y4 = x1 - x5
y5 = x1 - x6

strFormula = "=R[-" & y1 & "]C+R[-" & y2 & "]C+R[-" & y3 & "]C+R[-" & y4 & "]C+R[-" & y5 & "]C"
varVar = InsertToCells(strFormula)




End Function


Function InsertToCells(strFormula As String)

varVar = CellPrep(3)
ActiveCell.Formula = strFormula

varVar = CellPrep(2)
ActiveCell.Formula = strFormula

varVar = CellPrep(8)
ActiveCell.Formula = strFormula

i = 0
Do Until i = 5
varVar = CellPrep(2)
ActiveCell.Formula = strFormula
i = i + 1
Loop

End Function
Function CellPrep(intOffset As Integer)
ActiveCell.Offset(0, intOffset).Select
With Selection.Font
.Underline = xlUnderlineStyleDoubleAccounting
End With
Selection.NumberFormat = "0.00"
End Function
_________________
I can't decide whether I want to be a Ludite or a technogeek.

Post Fri Sep 19, 2003 8:10 pm 
 View user's profile Send private message Send e-mail AIM Address Yahoo Messenger

Richie(UK)
MrExcel MVP


Joined: 18 May 2002
Posts: 2464
Location: Worcester, England
Flag: Uk

Status: Offline

 Reply with quote  

Re: Scary and Confusing Formula Problem

For reference this query has also been posted here:

http://www.theofficeexperts.com/forum/showthread.php?s=&threadid=2134
_________________
Richie

Post Tue Sep 23, 2003 7:50 pm 
 View user's profile Send private message

Yesuslave
Board Regular


Joined: 19 Sep 2003
Posts: 97
Location: New Jersey
Flag: Usa

Status: Offline

 Reply with quote  

Re: Scary and Confusing Formula Problem

Though i did not find out the answer to this question, I did create a loop that checks to see if a cell's sum equals 0. If it does, I did not include it in the formula.

Thanks anyway...looking forward to learning a lot here.

Joshua Wise
_________________
I can't decide whether I want to be a Ludite or a technogeek.

Post Wed Sep 24, 2003 8:32 pm 
 View user's profile Send private message Send e-mail AIM Address Yahoo Messenger
  Display posts from previous:      

MrExcel Message Board Forum Index -> Excel Questions


Forum Jump:
Jump to:  

Post new topic   Reply to topic
Page 1 of 1



Add To Favorites

 


Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Powered by phpBB: 2.0.4 © 2001 phpBB Group

Need help posting your first question? Read how to post

Need extra help ? Couldn't get the answer you needed ? Get a free quote from our Consulting Team

Download Colo's HTML Maker utility for displaying your Excel Worksheet on the board.

Download VB HTML Maker to post your code on the board


Check out our new index to 485 Excel Articles.


Return to MrExcel Consulting

All contents Copyright 1998-2004 by MrExcel.com
If you believe information posted here is from your copyrighted source, notify us per the Terms of Use
Excel is a registered trademark of the Microsoft Corporation.
MrExcel is a registered trademark of Tickling Keys, Inc.