Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 339
Default It doesn't add up - It's driving me crazy

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
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!! IF OR formula driving me crazy!!!! caz - can't use excel!! Excel Discussion (Misc queries) 8 August 13th 09 09:07 PM
Driving me CRAZY~ please help Tara New Users to Excel 0 July 7th 08 07:29 PM
Formula is driving me crazy????? Chris Watson Excel Worksheet Functions 19 February 13th 06 07:12 PM
VLOOKUP driving me crazy LB79 Excel Discussion (Misc queries) 5 December 13th 05 04:14 PM
Driving me crazy! Dick Kusleika[_3_] Excel Programming 0 October 21st 03 10:18 PM


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