Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Simple beginner question


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 Roper
------------------------------------------------------------------------
Jeff Roper's Profile: http://www.excelforum.com/member.php...o&userid=16293
View this thread: http://www.excelforum.com/showthread...hreadid=276913

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Simple beginner question

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)


"Jeff Roper" wrote in message
...

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 Roper
------------------------------------------------------------------------
Jeff Roper's Profile:

http://www.excelforum.com/member.php...o&userid=16293
View this thread: http://www.excelforum.com/showthread...hreadid=276913



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Simple beginner question

Have you looked at Tools=Goal Seek.

--
Regards,
Tom Ogilvy

"Jeff Roper" wrote in message
...

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 Roper
------------------------------------------------------------------------
Jeff Roper's Profile:

http://www.excelforum.com/member.php...o&userid=16293
View this thread: http://www.excelforum.com/showthread...hreadid=276913



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 690
Default Simple beginner question

I may not understand the question, but would this work?
Percent = Number1 - Number2 ?

--
Dana DeLouis
Win XP & Office 2003


"Jeff Roper" wrote in message
...

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 Roper
------------------------------------------------------------------------
Jeff Roper's Profile:
http://www.excelforum.com/member.php...o&userid=16293
View this thread: http://www.excelforum.com/showthread...hreadid=276913



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
Formula question from beginner JPorter Excel Discussion (Misc queries) 3 May 2nd 08 06:41 PM
Beginner Question Bernie Charts and Charting in Excel 0 February 13th 07 04:31 PM
Beginner question! Pat Excel Discussion (Misc queries) 3 August 7th 06 09:19 AM
Beginner question Tom. Excel Discussion (Misc queries) 1 April 24th 06 06:08 AM
Beginner VBA question light Excel Programming 1 November 10th 04 01:44 PM


All times are GMT +1. The time now is 01:38 AM.

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"