Simple beginner question

  • Thread starter Thread starter Jeff Roper
  • Start date Start date
J

Jeff Roper

I have just started using Excel 2003 and VBA in Excel. So I hope no one
laughs at me. Ok I have a worksheet that I am working with that changes
a percentage (increases by .001%) so that two numbers equal each other.
The Percent amount starts at 1% (which doesn't need to be shown in the
code).

I've been working with this subroutine:

Sub AddPercentage()

Dim NumberA, NumberB, Percent As Integer
Number1 = Range("I16")
Number2 = Range("K16")
Percent = Range("L7")

If Not Number1 = Number2 Then
Percent = Percent + 0.00001
End If

End Sub

Can someone help me out here? I would really appreciate it. :)
 
Jeff,

Few points.

If working with decimals, you cannot declare you variables as integer, they
should be Double.

You shouldn't declare variable NumberA, and then use Number1 in the code,
they are different.

You need some sort of loop to repeat the action until termination.

It is possible that this criteria, until equal will never happen, as the
addition of 0.001% each time will mean that it gets very close to the other
number, but not exactly equal it.

And what do you want to do with Percent, Number1 and Number2 at the end.

A bit of clarification needed.

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
I may not understand the question, but would this work?
Percent = Number1 - Number2 ?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Simple beginner question 2
HELP WITH A FORM IN EXCEL. 3
If,Then,Else Macro 2
Array to Multiple Arrays 3
Having problems w/ Solver code 3
VBA 3
Subtracting Dates VBA 1
Subtracting Dates VBA 6

Back
Top