How can I count to 10 while summing the numbers in VBA?
From stackoverflow
Janie
-
Dim Sum as Integer Sum = 0 Dim I as Integer For I = 1 to 10 Sum = Sum + I Next
Edit: For future reference, please refer to Microsoft's MSDN section on Visual Basic for Applications (VBA)
Janie : Thank you, this was really hard.WowtaH : Dim Sum, LOL ;)Janie : Hee hee, Lunchtime!!!gnovice : Mmmmm, dim sum!From TheTXI -
The question is labeled VB6, so:
Dim Sum As Integer Dim i As Integer For i = 1 To 10 Sum = Sum + i Next i
Shog9 : @A: if you're really not worried about verbosity, use `theVariableImUsingToCountToTenWith` instead of `i`Geoffrey Chetwood : I like the anal retentive verbosity advocate who only uses his initial for his first name.TheTXI : @Shog9: if you're really not worried about verbosity, use 'iHaveNoIdeaWhetherThisWouldWorkAsAPossibleVariableNameInVBASoIGuessItIsWorthAShotSoIAmCreatingASuperLongVariableNameToHoldSoThatICanWriteAForLoopFromOneToTen'From Jay Riggs -
Why do you need to use VBA to do this, your using excel, couldn't you just put the numbers 1 to 10 in different cells and add them up. Why do you even need to use excel. Couldn't you just type 1+2+3+4+5+6+7+8+9+10 into a calculator. Why do you even need to use a calculator, why can't you just work it out in your head.
TheTXI : If I had downvotes left, I'd downvote you just for being extremely late to this party.Pesto : Some of us can't handle two-digit addition in our heads, you insensitive clod.Janie : Um, because i'm trying to LEARN VBA. I'm familiar with calculators, thanks.From Andrew Marsh
0 comments:
Post a Comment