ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   help with generating a percentage value (https://www.excelbanter.com/excel-programming/445461-help-generating-percentage-value.html)

[email protected]

help with generating a percentage value
 
Hi,

I have a simple program that scrolls through a row collecting numbers,
at various points in the row i am trying to calulate a percentage.

i keep getting an error with the below code, (not very advanced)

Range("f9").Select
Do Until ActiveCell = ""
Selection.Offset(0, 1).Select
volume = ActiveCell
Selection.Offset(0, 1).Select
comp = ActiveCell
Selection.Offset(0, 1).Select
compercent = comp / volume * 100 (this is where it debugs to giving
me an overflow error)
activecell = compercent



I have tried declaring my variables as integers and long still no joy

any help would be great

John

Don Guillett[_2_]

help with generating a percentage value
 
On Tuesday, March 13, 2012 6:07:41 AM UTC-5, wrote:
Hi,

I have a simple program that scrolls through a row collecting numbers,
at various points in the row i am trying to calulate a percentage.

i keep getting an error with the below code, (not very advanced)

Range("f9").Select
Do Until ActiveCell = ""
Selection.Offset(0, 1).Select
volume = ActiveCell
Selection.Offset(0, 1).Select
comp = ActiveCell
Selection.Offset(0, 1).Select
compercent = comp / volume * 100 (this is where it debugs to giving
me an overflow error)
activecell = compercent



I have tried declaring my variables as integers and long still no joy

any help would be great

John


KISS

range("i9").value = range("g9")/range("h9")* 100


Range("f9").Select
Do Until ActiveCell = ""
Selection.Offset(0, 1).Select
volume = ActiveCell
Selection.Offset(0, 1).Select
comp = ActiveCell
Selection.Offset(0, 1).Select
compercent = comp / volume * 100 (this is where it debugs to giving
me an overflow error)
activecell = compercent

[email protected]

help with generating a percentage value
 
On Mar 13, 11:40*am, Don Guillett wrote:
On Tuesday, March 13, 2012 6:07:41 AM UTC-5, wrote:
Hi,


I have a simple program that scrolls through a row collecting numbers,
at various points in the row i am trying to calulate a percentage.


i keep getting an error with the below code, (not very advanced)


Range("f9").Select
* Do Until ActiveCell = ""
* Selection.Offset(0, 1).Select
* volume = ActiveCell
* Selection.Offset(0, 1).Select
* comp = ActiveCell
* Selection.Offset(0, 1).Select
* compercent = comp / volume * 100 *(this is where it debugs to giving
me an overflow error)
activecell = compercent


I have tried declaring my variables as integers and long still no joy


any help would be great


John


KISS

range("i9").value = range("g9")/range("h9")* 100

Range("f9").Select
* Do Until ActiveCell = ""
* Selection.Offset(0, 1).Select
* volume = ActiveCell
* Selection.Offset(0, 1).Select
* comp = ActiveCell
* Selection.Offset(0, 1).Select
* compercent = comp / volume * 100 *(this is where it debugs to giving
me an overflow error)
activecell = compercent- Hide quoted text -

- Show quoted text -


Hi

Thanks

sorry i fogot a bit of my code

Range("f9").Select
Do Until ActiveCell = ""
Selection.Offset(0, 1).Select
volume = ActiveCell
Selection.Offset(0, 1).Select
comp = ActiveCell
Selection.Offset(0, 1).Select
compercent = comp / volume * 100 (this is where it debugs to
giving
me an overflow error)
activecell = compercent
Selection.Offset(0, 1).Select
loop


The code loops through alot of cells adding percentages as it goes,
hence why i have used variables

thanks



[email protected]

help with generating a percentage value
 
On Mar 13, 11:40*am, Don Guillett wrote:
On Tuesday, March 13, 2012 6:07:41 AM UTC-5, wrote:
Hi,


I have a simple program that scrolls through a row collecting numbers,
at various points in the row i am trying to calulate a percentage.


i keep getting an error with the below code, (not very advanced)


Range("f9").Select
* Do Until ActiveCell = ""
* Selection.Offset(0, 1).Select
* volume = ActiveCell
* Selection.Offset(0, 1).Select
* comp = ActiveCell
* Selection.Offset(0, 1).Select
* compercent = comp / volume * 100 *(this is where it debugs to giving
me an overflow error)
activecell = compercent


I have tried declaring my variables as integers and long still no joy


any help would be great


John


KISS

range("i9").value = range("g9")/range("h9")* 100

Range("f9").Select
* Do Until ActiveCell = ""
* Selection.Offset(0, 1).Select
* volume = ActiveCell
* Selection.Offset(0, 1).Select
* comp = ActiveCell
* Selection.Offset(0, 1).Select
* compercent = comp / volume * 100 *(this is where it debugs to giving
me an overflow error)
activecell = compercent- Hide quoted text -

- Show quoted text -


sorry i forgot part of the code

Range("f9").Select
Do Until ActiveCell = ""
Selection.Offset(0, 1).Select
volume = ActiveCell
Selection.Offset(0, 1).Select
comp = ActiveCell
Selection.Offset(0, 1).Select
compercent = comp / volume * 100 (this is where it debugs to
giving
me an overflow error)
activecell = compercent
activecell.offset(0,1).select
loop

the code loops through the cells picking up the values and adding a
percentage, until it comes to the end of the list

many thanks









Claus Busch

help with generating a percentage value
 
Hi John,

Am Tue, 13 Mar 2012 05:38:07 -0700 (PDT) schrieb
:

the code loops through the cells picking up the values and adding a
percentage, until it comes to the end of the list


every third column is empty? Then try:

Dim LCol As Long
Dim i As Long

LCol = Cells(9, Columns.Count).End(xlToLeft).Column + 1
For i = 9 To LCol Step 3
Cells(9, i) = Cells(9, i - 1) / Cells(9, i - 2) * 100
Next

or:

Dim LCol As Long
Dim i As Long

LCol = Cells(9, Columns.Count).End(xlToLeft).Column + 1
For i = 9 To LCol Step 3
Cells(9, i) = Cells(9, i - 1) / Cells(9, i - 2)
Cells(9, i).NumberFormat = "0.00%"
Next


Regards
Claus Busch
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2


All times are GMT +1. The time now is 02:20 AM.

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