Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
It seems as if you only sum the values in cell A1.
For Each c In Range("A1").CurrentRegion.Cells Shouldn't this line be rewritten as For Each c In Range("A1:A5").CurrentRegion.Cells /Fredrik "Francis Hayes (The Excel Addict)" wrote in message ... Sorry about that previous post. I was typing away and before I was finished my post disappeared. Here's the complete post... ------------------------------------------- I need someone to tell me I'm not going crazy. Please try this. Enter the following data into a blank worksheet. A1=.2 A2=.2 A3=.2 A4=.2 A5=.2 Notice that it adds up to 1 (i.e. 100%) Copy this macro (below) into the workbook and run it. Sub DoesntAddUp() For Each c In Range("A1").CurrentRegion.Cells amt = amt + c Next c If amt < 1 Then MsgBox "Sorry, your total is < 1. Your total is = " & amt Else MsgBox "Congratulations. Your total is " & amt End If End Sub You should get a message saying 'Congratulations. Your total is =1' Now, change A1 to .3 and A5 to .1 Now run the macro again. Did you get a message saying 'Sorry, your total is < 1. Your total is = 1'? Step through the macro and notice on the line 'If amt < 1 Then' that the variable amt = 1 but this still evaluates to TRUE. Can someone explain to me what's happening? I've tried this on several computers, each time with the same result. Thanks for your help. Francis |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Need HELP!! IF OR formula driving me crazy!!!! | Excel Discussion (Misc queries) | |||
Driving me CRAZY~ please help | New Users to Excel | |||
Formula is driving me crazy????? | Excel Worksheet Functions | |||
VLOOKUP driving me crazy | Excel Discussion (Misc queries) | |||
Driving me crazy! | Excel Programming |