ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Simple beginner question (https://www.excelbanter.com/excel-programming/316417-simple-beginner-question.html)

Jeff Roper[_2_]

Simple beginner question
 

Ok, I think I am really close to figuring this one out. This actuall
cycles through, but does not stop at the equal values. I trie
rounding the numbers (that one is adjusting to the other to be equal)
but it still doesn't stop when they are equal.

Sub AddPercentage()

Dim Number1, Number2, Percent As Double
Number1 = Range("I16")
Number2 = Range("K16")
Range("L7").Value = 0.05


Do While Not Round(Number1, 2) = Round(Number2, 2)
Range("L7") = Range("L7") + 0.00001
Loop

End Sub


Is there a way to get this to work? It's nice to be able to make
macro actually do something. Thanks. :

--
Jeff Rope
-----------------------------------------------------------------------
Jeff Roper's Profile: http://www.excelforum.com/member.php...fo&userid=1629
View this thread: http://www.excelforum.com/showthread.php?threadid=27691


mangesh_yadav[_189_]

Simple beginner question
 

Your objective is still unclear. What are the values / formulae in th
cells I16, K16 and L

--
mangesh_yada

-----------------------------------------------------------------------
mangesh_yadav's Profile: http://www.excelforum.com/member.php...fo&userid=1047
View this thread: http://www.excelforum.com/showthread.php?threadid=27691


Frank Kabel

Simple beginner question
 
Hi Jeff
the problem is that your Number 1 and Numer 2 actually store the initial
assigne values of these two cells and are NOT updated in your loop. You may
try the following (Also watch the dIM statements. You have to assign the type
to each of your variables individually):

Sub AddPercentage()

Dim Number1 as range
Dim number2 as range
set Number1 = Range("I16")
set Number2 = Range("K16")
Range("L7").Value = 0.05


Do While Not Round(Number1.value, 2) = Round(Number2.value, 2)
Range("L7").value = Range("L7").value + 0.00001
Loop
End Sub

Not sure though how changing cell L7 changes either cell I16 or K16 as you
compare these two cells??




"Jeff Roper" wrote:


Ok, I think I am really close to figuring this one out. This actually
cycles through, but does not stop at the equal values. I tried
rounding the numbers (that one is adjusting to the other to be equal),
but it still doesn't stop when they are equal.

Sub AddPercentage()

Dim Number1, Number2, Percent As Double
Number1 = Range("I16")
Number2 = Range("K16")
Range("L7").Value = 0.05


Do While Not Round(Number1, 2) = Round(Number2, 2)
Range("L7") = Range("L7") + 0.00001
Loop

End Sub


Is there a way to get this to work? It's nice to be able to make a
macro actually do something. Thanks. :)


--
Jeff Roper
------------------------------------------------------------------------
Jeff Roper's Profile: http://www.excelforum.com/member.php...o&userid=16293
View this thread: http://www.excelforum.com/showthread...hreadid=276913




All times are GMT +1. The time now is 12:02 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com